mysql中檢查列名是否存在
阿新 • • 發佈:2019-02-09
今天在做一個功能的時候用到了,資料表列名檢查。網上查閱,接收了下新知識。記錄分享---
不多說,直接上sql語句:
declare vTableName,vCurrentDatabase varchar(50);
declare vEmpConfirmState varchar(15);
set vTableName = json_extract(datas,'$.tableName');
select database() into vCurrentDatabase;
if not exists (select * from INFORMATION_SCHEMA.COLUMNS where table_name = vTableName and column_name = 'empConfirmState') then
set rlt= concat('{"success":false,"msg":"<font style= color:red><b>警告:該模組沒有需員工確認項...</b></font>"}');
end if;