I am looking for help in writing a MYSQL query. I have two tables, one called users and another called switched. The users table has the following structure:
uid
first_name
last_name
And the switched table:
uid (references user table)
switch_number
reg_date
The switched table has multiple uid values and I wish to generate a table with the following output:
uid | switches
Where switches refers to the number of occurrences in the switched table. Could someone please guide me on how to do this using MySQL and PHP. I appreciate any help.
Regards,
Select UID, count(Switches) from switched group by UIDseems like what your after but I can't tell. counting switches means NULL switch_numbers will be omitted if that situation exists.