Showing posts with label tickets. Show all posts
Showing posts with label tickets. Show all posts

Monday, February 20, 2012

MSSQL SELECT error

I've the following Select Statement that generates errors, could someone tells me why? :(

SELECT TOP 20 * FROM tickets WHERE ticket_ID NOT IN (SELECT TOP 20 * FROM tickets ORDER BY ticket_ID DESC) ORDER BY ticket_ID DESC;

Warning: mssql_query() [function.mssql-query]: message: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. (severity 16) in c:\Inetpub\wwwroot\schoolProject\admin\show.php on line 437Try this ??

SELECT TOP 20 * FROM tickets WHERE ticket_ID NOT IN (SELECT TOP 20 ticket_ID FROM tickets ORDER BY ticket_ID DESC) ORDER BY ticket_ID DESC

You had it checking the id against all columns - take it you are trying to get the 21st to 40th most recent??