MySQL Forums
Forum List  »  Newbie

MySQL query or two tables
Posted by: ubermac
Date: April 01, 2005 08:09PM

I have two tables:
cases: (caseID, caseName)
files: (fileID, FileName, fileDescription, fileCaseID)

I need to output a table of all of the cases and if the cases have a file associated with it (fileCaseID has the caseID for the associated case) the file info shoud appear as well. I have come up with this query:
SELECT * FROM cases JOIN files ON cases.caseID=files.fileCaseID WHERE files.fileUsers LIKE '%1%'

But it only returns the first case that has a file associated with it.

I need to retireve all cases and if a case has files associated with the case, get the file data ase well. What am i doing wrong? i have tried to relate two separate queries, loop through the cases and for each case loop throug the files to find any associated files and fitting it all into a single query, all to no avail.

Please help!!

Thanx in advance.

Options: ReplyQuote


Subject
Written By
Posted
MySQL query or two tables
April 01, 2005 08:09PM
April 01, 2005 08:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.