How can I check if mysql table column even exists?

后端 未结 8 980
闹比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

    Another way of doing it in PHP:

    $chkcol = mysql_query("SELECT * FROM `table_name` LIMIT 1"); 
    $mycol = mysql_fetch_array($chkcol); 
    if(isset($mycol['price'])) 
      echo "Column price exists! Do something...";
    

提交回复
热议问题