是否可以 ?
INSERT INTO tblPeople (id, group, company) VALUES (1, 'myGroup', IF($company = '') BEGIN 'no company' ELSE 'myCompany' END)
我想测试一个值,如果变量 $company 为空,我想写 no company。
是否可以 ?
INSERT INTO tblPeople (id, group, company) VALUES (1, 'myGroup', IF($company = '') BEGIN 'no company' ELSE 'myCompany' END)
我想测试一个值,如果变量 $company 为空,我想写 no company。
试试这个:
INSERT INTO tblPeople (id, group, company)
select 1, 'myGroup',
case
when @company is null or @company = '' then 'no company'
else 'myCompany'
END as company
/*from tab --<-- optional*/
可能不是,但是
INSERT INTO tblPeople (id, [group], company)
Select 1, 'myGroup', Case When @Company = '' then 'no company' Else 'my company' End
应该是路人