I have two tables, MAIN and ASSOCIATED. MAIN contains three fields: id, name, and location. ASSOCIATED contains two fields: id_1 and id_2. Both of these fields contain id's from MAIN. In other words, records from MAIN can be related to each other through the ASSOCIATED table.
I want to see how many records in MAIN have related records in MAIN. I also want to see how many total records there are for each location, and the number of records with related records per location.
I'm having trouble with this. Can anybody help? What do I group by? Location first and then id from the left hand version of MAIN?
Thanks in advance.
I want to see how many records in MAIN have related records in MAIN. I also want to see how many total records there are for each location, and the number of records with related records per location.
I'm having trouble with this. Can anybody help? What do I group by? Location first and then id from the left hand version of MAIN?
Thanks in advance.