How can I check if mysql table column even exists?

后端 未结 8 1008
闹比i
闹比i 2020-12-30 08:44

How can I check if mysql table field even exists ?

The column name is \'price\' and I need to see if it exists.

Haven\'t understood really how the \'EXISTS\'

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 09:10

    I found this very useful. It will list all the tables that has that column name.

    SELECT table_name, 
           column_name 
    FROM   information_schema.columns 
    WHERE  column_name LIKE '%the_column_name%' 
    

提交回复
热议问题