SQL search all columns of a table for text value

后端 未结 3 1952
后悔当初
后悔当初 2021-01-16 02:20

I have a huge table with many columns and I know that this columns sometimes takes some specific value \'MyValue\'. How can I select all the rows in that one specific table

3条回答
  •  情话喂你
    2021-01-16 02:43

    You can do this by reversing the value and column in In operator.

    SELECT *
    FROM   Mytable
    WHERE  'Myvalue' IN ( Col1, Col2, col3,.... ) 
    

    If you don't want to type the columns, then pull it from information_schema.column view and create a dynamic query

提交回复
热议问题