Hi, I have a database with only one table as below:
userurltag(id,userID(string),Url(String),tag(String))
I want to delete users that have less than 3 urls associated with them. How can I do that?
Hi, I have a database with only one table as below:
userurltag(id,userID(string),Url(String),tag(String))
I want to delete users that have less than 3 urls associated with them. How can I do that?
DELETE
FROM userurltag
WHERE UserID IN
(SELECT UserID FROM userurltag GROUP BY userID Having COUNT(UserID) < 3)
Try this one:
DELETE
FROM userurltag USING userurltag
JOIN
(SELECT userID
FROM userurltag
GROUP BY userID HAVING COUNT(*) < 3) as tmp
ON userurltag.userID = tmp.userID;