[英]Syntax error:MySQL Insert Select
我有此查询要插入到tbl_userprofile中:
$SQL = "INSERT INTO tbl_userprofile (userId, name, surname, gender, nationality, address, mobile, department, email, question, answer)
SELECT tbl_user.Id , '$name', '$surname', '$gender', '$nationality', '$address','$mobile', '$department', '$email', '$question', '$answer'
FROM tbl_user
WHERE username = '$uname'";
我收到一个语法错误,说:“您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以获取正确的语法,以便在'pet-peeve','dirt'处使用from FROM tbl_user WHERE username =第2行的“ alex””
注意:宠物怒气冲冲和肮脏是问题和答案。 我不知道我怎么得到语法错误。 请问我的语法错误在哪里? 谢谢
在最后两个字段中可能会有一些纯文本,因此可能会有引号,最好在$question
和$answer
变量中使用addslashes()
'$email', '".addslashes($question)."', '".addslashes($answer)."' FROM tbl_user
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.