我有两张表 - char_items
和items
。 item_id是两个表中的公共字段。
我想从' char_items'中读取item_id表格并用于从“&...”项目中获取其他信息。基于该item_id的表。但我的查询在MySQL中显示为不正确。请帮忙 -
SELECT * FROM `char_items` WHERE char_id=$char_id && isSlotted=1 INNER JOIN `items` ON char_items.item_id=items.item_id
我一直收到消息:
#1064 - 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 'INNER JOIN `items` ON char_items.item_id=items.item_id
LIMIT 0,30'在第1行
答案 0 :(得分:0)
联接需要在where子句
之前发生SELECT *
FROM char_items c
INNER
JOIN items i
ON c.item_id = i.item_id
WHERE char_id = $char_id
AND isSlotted = 1
答案 1 :(得分:0)
应该在join子句之后,如下所示。
SELECT * FROM `char_items` INNER JOIN `items` ON char_items.item_id=items.item_id WHERE char_id=$char_id && isSlotted=1;