有可能吗?
INSERT INTO tblPeople (id, group, company) VALUES (1, 'myGroup', IF($company = '') BEGIN 'no company' ELSE 'myCompany' END)
我想测试一个值,如果变量$ company是空的,我想不写公司。
答案 0 :(得分:25)
试试这个:
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*/
答案 1 :(得分:6)
可能不是,但是
INSERT INTO tblPeople (id, [group], company)
Select 1, 'myGroup', Case When @Company = '' then 'no company' Else 'my company' End
应该是一个观众