How can I check if mysql table column even exists?

后端 未结 8 1004
闹比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:02

    Well, one way is to do:

    select price from your_table limit 1
    

    If you get an error:

    #1054 - Unknown column 'price' in 'field list'
    

    then it does not exists.

提交回复
热议问题