我有这张桌子:
... | products | ...
... | 1, 5, 5 | ...
... | 3, 1, 6 | ...
这个查询:
SELECT
orders.id,
orders.user_id,
users.username,
orders.products,
orders.rating,
orders.payment,
orders.comment
FROM
orders JOIN users
ON orders.user_id = users.id
WHERE
FIND_IN_SET(1, REPLACE(orders.products, ' ', '')) > 0;
我需要获取这些行,但它没有给我任何结果,我只使用表orders
尝试了查询,并且它有效。那么为什么它不适用于JOIN
?
答案 0 :(得分:-1)
尝试此查询:
SELECT
orders.id,
orders.user_id,
users.username,
orders.products,
orders.rating,
orders.payment,
orders.comment
FROM
orders JOIN users
ON orders.id = users.id
WHERE
FIND_IN_SET(1, REPLACE(orders.products, ' ', '')) > 0;
我已将user_id
更改为加入两个表的行中的id
。