我想将一些与答案相关的数据插入到mysql表中。第一个问题是每次运行脚本时都会失败:
INSERT INTO outgoing_sms (timestamp,dest_msisdn,text_message,sender_name,service_id)
VALUES (now(),last_inserted_number, CASE last_inserted_message
WHEN 'no' THEN "you choose not to secure with payslip."
WHEN 'yes' THEN "you choose to secure with payslip."
ELSE "Invalid choice."
END, 90294,0000002000099451);
第二个问题:mysql是否会考虑"是" /"不"或"是"和"否"或"是" /"否"或者" yeS" /" nO"。
我的查询应该不区分大小写;所有角色都是正确的就足够了。
答案 0 :(得分:0)
对于错误,您的语法似乎无效。我没有要测试的mySql实例,但这应该可行:
INSERT INTO outgoing_sms (timestamp,dest_msisdn,text_message,sender_name,service_id)
VALUES (now(),last_inserted_number,
CASE last_inserted_message
WHEN 'no' THEN SELECT "you choose not to secure with payslip.";
WHEN 'yes' THEN SELECT "you choose to secure with payslip.";
ELSE "Invalid choice.";
END CASE;,
90294,0000002000099451);
处理下部套管的最简单方法是在提交之前对数据进行虚拟转换,例如。 no = 0,yes = 1。