开发者

Selecting multiple values from 2 columns in MySQL

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

  • t开发者_JAVA百科own=Abingdon and type=type2


Maybe this will work:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜