当我提供“Tim”(WHERE userName ='Tim')时,如何从订购的产品中删除用户ID 00002。不是userID,我很清楚它。
User Info
------------------
userID | userName
00001 | Jim
00002 | Tim
00003 | Steve
00004 | Boo
Product Ordered
------------------
userID | ProductCode
00002 | p0001
00002 | p0003
00001 | p0002
00003 | p0001
答案 0 :(得分:1)
DELETE po.*
FROM `Product ordered` po
INNER JOIN `User Info` ui
ON ui.userID = po.userID
WHERE ui.userName = 'Tim'
应该这样做。
答案 1 :(得分:0)
DELETE FROM product_ordered
WHERE userID IN (
SELECT userID FROM user_info
WHERE userName='Tim'
)