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开发者_Python百科 gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc
Unfortunately, there is no error function in SQL Server. Instead, use mssql_get_last_message()
.
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.
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
精彩评论