如何处理涉及多个表的SQL查询

时间:2013-05-01 13:10:14

标签: mysql inner-join

我有下一个表格结构

table_one

+-----+------+
| id  | ref  |
+------------+

table_two

+---------+-------+
| id_one  | cont  |  >> Where id_one references id (from first table)
+-----------------+

我正在尝试执行

之类的查询
SELECT t1.id FROM table_one t1
INNER JOIN table_two t2 ON t2.id_one=t1.id
WHERE t2.cont IN (int,int,int,int...)
AND t1.ref=1 LIMIT 0,1

...并且收到此错误(在phpMyAdmin上)

  

1064 - 您的SQL语法出错;检查附近的[..]:
  '值t1 INNER JOIN values_int t2 ON t2.id_v = t1.id WHERE t2.cont IN   (8,13)'

感谢阅读。

1 个答案:

答案 0 :(得分:2)

values是这样的reserved word转义:

...
FROM `values` t1
INNER JOIN ....