GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Aug-2005, 13:58
robophobic robophobic is offline
New Member
 
Join Date: Aug 2005
Posts: 1
robophobic is on a distinguished road

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  
Old 09-Aug-2005, 08:39
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
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.
 

Recent GIDBlogPrepping for deployment by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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

All times are GMT -6. The time now is 21:15.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.