PHP SQL Server 错误跟踪

发布于 2024-11-09 09:35:12 字数 347 浏览 0 评论 0原文

我正在使用大家都知道的函数 mysql_error 来跟踪 mysql 错误。但是,我正在从 SQL Server 访问记录,为此我使用了 PHP 提供的所有 mssql_ 函数。

我的一个查询没有被执行,我不确定我在哪里犯了错误。谁能告诉我,SQL Server 跟踪数据库错误的确切函数是什么(在 PHP 中可用)。

SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc

I am tracking mysql errors using the function mysql_error that everyone knows. But, I am accessing records from SQL Server, For that i have used all the mssql_ functions which are provided by PHP.

One of my queries is not getting executed and am not sure where i did the mistake. Can any one please tell me, what is the exact function for SQL Server to track the DB errors(available in PHP).

SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

魄砕の薆 2024-11-16 09:35:12

不幸的是,SQL Server 中没有错误函数。相反,请使用 mssql_get_last_message()

Unfortunately, there is no error function in SQL Server. Instead, use mssql_get_last_message().

赴月观长安 2024-11-16 09:35:12

这是一个简单的选择sql。如果我是你,我想在 SQL Server Management Studio 中运行它。除此之外,请尝试此链接 http:// www.php.net/manual/en/function.mssql-get-last-message.php#21728 其中有人尝试使用通用错误处理存储过程解决问题。

This is a simple select sql. I would want to run this in SQL Server Management Studio, if I were you. Apart from that, try this link http://www.php.net/manual/en/function.mssql-get-last-message.php#21728 where someone has tried to resolve issues using a GENERIC ERROR HANDLING Stored Procedure.

滿滿的愛 2024-11-16 09:35:12
SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc

这永远行不通,因为您正在使用 GROUP BY 子句。您需要指定要显示的字段。所以像这样:

SELECT
    postalcode, region3
FROM
    gb
WHERE
    postalcode LIKE 'YO1%' OR place LIKE 'YO1%'
GROUP BY 
    postalcode, region3
ORDER BY 
    postalcode ASC
SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc

This can never work, as you are using the GROUP BY clause. You will need to specify which fields to show. So something like:

SELECT
    postalcode, region3
FROM
    gb
WHERE
    postalcode LIKE 'YO1%' OR place LIKE 'YO1%'
GROUP BY 
    postalcode, region3
ORDER BY 
    postalcode ASC
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文