简体   繁体   English

在MySQL中名为“ like”的表

[英]Table named 'like' in MySQL

I didn't realize 'like' was a keyword in SQL when I built my table. 构建表时,我没有意识到“ like”是SQL中的关键字。 Now I get an error when I try insert into the row because 'like' is a SQL keyword. 现在,当我尝试插入到行中时出现错误,因为'like'是一个SQL关键字。

error: You have an error in your SQL syntax; 错误:您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like VALUES (DEFAULT, NOW(), 'kirkins@gmail.com', '12345678')' at line 1 检查与您的MySQL服务器版本相对应的手册,以在第1行的'like VALUES(DEFAULT,NOW(),'kirkins@gmail.com','12345678')'附近使用正确的语法

Can I modify my insert to specify that I mean the table named like and not the like keyword? 我可以修改我的插入内容以指定我的意思是名为like而不是like关键字的表吗?

$sql = "INSERT INTO like VALUES (DEFAULT, NOW(), '$email', '$post_id')";

像这样尝试:

$sql = "INSERT INTO `like` VALUES (DEFAULT, NOW(), '$email', '$post_id')";

用对号转义表名:

$sql = "INSERT INTO `like` VALUES (DEFAULT, NOW(), '$email', '$post_id')";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM