Ok I want here to make a query which will reuse the result of a count(*) function.
lets say my website does events at different places for the same date, and also at different dates:
this makes a structure like this:
Expand|Select|Wrap|Line Numbers
- event_id | attending_id | date
-multiple records with the same event_id and different attending_id
("different attendants to the same event for a specific date")
-multiple records with different event_id and different attending_id
("different attendants are going to different events the same date")
repeat these two possibilities for different dates
i could have:
Expand|Select|Wrap|Line Numbers
- date1 - john - best poker
- date1 - bob - best poker
- date1 - pip - best poker
- date1 - ron - poker unite
- date1 - clo - poker unite
- date1 - foo - poker unite
- date1 - fos - poker unite
- date1 - koh - gold poker
- date2 - ron - poker unite
- date2 - bob - poker unite
- date3 - bob - poker unite
- data3 - mar - poker hacks
Expand|Select|Wrap|Line Numbers
- SELECT count(*)
- FROM attending
- WHERE attending.date = '$date'
- ORDER by the most populated events
(for date1)
Expand|Select|Wrap|Line Numbers
- poker unite 4
- best poker 3
- gold poker 1
PD: in my real table the events are stored under id (numbers), so i should then get the names for each event from another table would that be possible in the same query?
thankyou
bilibytes