Page 1 of 1

mysql query question

Posted: Mon Dec 18, 2006 10:36 pm
by garry27
what can i add to the following query "SELECT pubID, pubName, pubPostcode from Pubs" so that it only returns results if the pubID='2' or pubID='5' or pubID='9' etc.

i know you can do it using where clauses in separate queries but can it be done in a single call?

thanks

Posted: Mon Dec 18, 2006 10:43 pm
by iknownothing

Code: Select all

SELECT pubID, pubName, pubPostcode FROM Pubs WHERE pubID IN ('2','5','9')

Posted: Tue Dec 19, 2006 12:14 am
by John Cartwright
iknownothing wrote:

Code: Select all

SELECT pubID, pubName, pubPostcode FROM Pubs WHERE pubID IN ('2','5','9')
lose the quotes for integers :wink: