I'm new to MYSQL and have been setting up something basic, I have several tables User, Purchase, Item User and Item share keys, Purchase shares keys with Item, I want to basically find a query that allows me to see what users (uid) have bought 2 or more items
I was going to try
SELECT uid FROM user
SELECT pid FROM Purchase
SELECT iid FROM Item WHERE itype...
And then I get lost, sorry if this sounds confusing.
You said User and Item share keys. If that means that each row in Item contains a uid then you can do this:
SELECT uid, COUNT(uid)
FROM Item
GROUP BY uid
HAVING COUNT(uid) > 1
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.