tags:

views:

34

answers:

1

Hi, I'm trying to select multiple values from 2 columns. I can get the query working with 1 column, eg:

SELECT *
FROM table
WHERE
    town IN ( 'Oxford' , 'Abingdon' )

However, I want to do something like:

SELECT *
FROM table
WHERE
    town IN ( 'Oxford' , 'Abingdon' )
AND type IN ( 'type1','type2')

but I can't get it to work.

Basically I want to select all where:

  • town=Oxford and type=type1

  • town=Oxford and type=type2

  • town=Abingdon and type=type1

  • town=Abingdon and type=type2

+1  A: 

Maybe this will work:

  SELECT * FROM table WHERE  (town IN ( 'Oxford' , 'Abingdon' )) AND (type IN ( 'type1','type2'))
killer_PL
Well, It must be a bad day! I must have had a typo AND was stupid enough not to check the error messages before posting! You're all right - The query I typed into my message works - DOH!
dmid