[mysql]檢查欄位是否存在MySQL–check column exists

參考網址:痞客邦

SQL指令–mySQL 檢查欄位是否存在 (MySQL–check which column exists in table)


SELECT count(*) FROM information_schema.columns WHERE table_schema='<Database Name>' AND table_name = '<Table Name>' AND column_name = '<Column Name>'

results as below:

0     if the <Column Name> doesn't exist;

1     otherwise.

本篇發表於 程式設計。將永久鏈結加入書籤。