I have this table:
... | products | ...
... | 1, 5, 5 | ...
... | 3, 1, 6 | ...
And this query:
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;
I need to get these rows but it gives me no result, I've tried the query using only the table orders
, and it works. So why it does not work with JOIN
?
Try this query:
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;
I have changed user_id
to id
in the line that joins the two tables.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.