Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 About where clause

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-01 : 07:58:28
Joel writes "Hi ,
Could you please tell me if there is any reserved word to select all from a field in the table . My query is as below
SELECT * FROM TABLE_NAME WHERE CITY="ALL"
Instead of 'ALL' in the city criteria I need to insert some reserved word where I could select all the records from all cities . I need to do this because I have to collect information from a form and then get the required query . so when all is selected in the drop down menu it should display all records.

Your help would be highly appreciated .

Regards ,

Joel ."

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2002-07-01 : 08:12:49
I'd suggest you check the value of City before you construct the SELECT statement.

IF @City = "ALL" Then
SELECT * FROM TABLE_NAME
Else
SELECT * FROM TABLE_NAME WHERE CITY = @City
End If
Go to Top of Page
   

- Advertisement -