mysql query question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
garry27
Forum Commoner
Posts: 90
Joined: Sat Oct 14, 2006 1:50 pm

mysql query question

Post 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
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

Code: Select all

SELECT pubID, pubName, pubPostcode FROM Pubs WHERE pubID IN ('2','5','9')
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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:
Post Reply