Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- users: categories:
- ╔═══════╦═══════════╗╔═══════╦═══════════╗
- ║ id ║ user_type ║║ id ║ name ║
- ╠═══════╬═══════════╣╠═══════╬═══════════╣
- ║ id 1 ║ tutor ║║ id 1 ║ name1 ║
- ║ id 2 ║ other ║║ id 2 ║ name2 ║
- ╚═══════╩═══════════╝╚═══════╩═══════════╝
- ads:
- ╔════════════╦══════════════╗
- ║ creator_id ║ category_id ║
- ╠════════════╬══════════════╣
- ║ user.id1 ║ category.id1 ║
- ║ user.id2 ║ category.id2 ║
- ╚════════════╩══════════════╝
- SELECT COUNT(DISTINCT users.id) AS count FROM users
- INNER JOIN ratings
- ON users.id = receiver_id
- LEFT JOIN ads
- ON users.id = ads.creator_id
- LEFT JOIN categories
- ON categories.id = ads.category_id
- WHERE user_type = "tutor"
- AND categories.name IN ("economy","anatomy")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement