MySQL子查询语法错误

标签 mysql

这个 MySQL 查询有什么问题?

    $result = mysql_query("SELECT did FROM publications where group IN 
(SELECT s_group FROM subscriptions where uid1='$id')") or die(mysql_error());

我收到语法错误:

        You have an error in your SQL syntax; check the manual that corresponds 
    to your MySQL server version for the right syntax to use near 's_group FROM 
subscriptions where uid1='34846')' at line 1

最佳答案

GROUP 是保留关键字。用 ` 括起来表示它是一个列名称:

SELECT did FROM publications where `group` IN 
(SELECT s_group FROM subscriptions where uid1=1)

关于MySQL子查询语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21042118/

相关文章:

mysql - mysql中如何实现交集和并集?

php - 将唯一标识符添加到 PHP for 循环中的第一次迭代

Mysql 在过程中从表中删除数据

php - 如何使用此 id 编写此查询?

MySQL REGEXP 匹配正数

MySQL表——设计高效的表

MySQL 堆栈过程性能修复,SELECT

php - MySQL 按连接值分组并获取每个组内的第一个 id (UUID)

c# - 无法在安全透明方法安全级别问题中执行 CAS 断言

php - Doctrine ——多对一;填充很多,无法在 DB 上使用常量 "ones"。如何手动插入FK?