Checking multiple columns for one value

后端 未结 3 1092
名媛妹妹
名媛妹妹 2020-11-28 05:45

I have a table that has columns like this for example:

id,col1,col2,col3,col4

Now, I want to check if ANY of col1, col2,

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 06:14

    I had a similar problem and solved it this way: SELECT * FROM table WHERE col1 OR col2 IN(SELECT xid FROM tablex WHERE somecol = 3)

    Not sure if it is "the best way" but it works for me.

    Thoughts?

提交回复
热议问题