Reputation: 45
How do I delete userID 00002 from Product ordered when I provided "Tim" (WHERE userName = 'Tim'). Not the userID, I'm very aware of it.
User Info
------------------
userID | userName
00001 | Jim
00002 | Tim
00003 | Steve
00004 | Boo
Product Ordered
------------------
userID | ProductCode
00002 | p0001
00002 | p0003
00001 | p0002
00003 | p0001
Upvotes: 2
Views: 39
Reputation: 80629
DELETE po.*
FROM `Product ordered` po
INNER JOIN `User Info` ui
ON ui.userID = po.userID
WHERE ui.userName = 'Tim'
That should do it.
Upvotes: 1
Reputation: 24276
DELETE FROM product_ordered
WHERE userID IN (
SELECT userID FROM user_info
WHERE userName='Tim'
)
Upvotes: 0