![]() |
|
#1
|
|||
|
|||
Is JOIN what I need?I'm trying to write a query that *should* be simple, but I'm having quite a bit of difficulty with it. I have two tables, one is College and the other Locations.
I need to pull up a list of all schools in the College table that also have an entry in the Locations table. Here's the query I used: SELECT college.id , college.name , sitting_msg , schooltype FROM college, location WHERE college.schooltype LIKE 'yearbook' AND location.college_id = college.id; The problem is that there are multiple entries for some colleges in the Locations table, and this query lists the college each time an entry is found in the Locations table. (i.e. Loyola U. has 3 locations, Gym, Library, Cafeteria, so the query result lists Loyola U. 3 times) Any idea how to get the query to just list each college once if it has multiple rows in the locations table while not listing it at all if there are no entries? |
|
#2
|
||||
|
||||
|
If you can paste an example (table) structure, some rows of data for each, and what you expect a query to return, I may be able to suggest something.
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
Prepping for deployment by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL/PHP inner join | ssalter | MySQL / PHP Forum | 2 | 03-Jan-2004 05:29 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The