This is what i have now:
SELECT id,type,value
FROM cart
WHERE Delete IS NULL
AND id IN (
SELECT id
from old.cart
WHERE delete is null
AND b_id = 15
)
I want to get "Name" column from "old.cart" like this:
SELECT id,type,value,Name
FROM cart
WHERE Delete IS NULL
AND id IN (
SELECT id,Name
from old.cart
WHERE delete is null
AND b_id = 15
)
How can I achive that ?
You don't need a subquery for this, just include the table in a join"
SELECT c.id, c.type, c.value, o.Name
FROM cart c
LEFT JOIN old.cart o ON c.id = o.id
AND o.b_id = 15
AND o.Delete IS NULL
WHERE c.Delete IS NULL
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.