Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LEFT OUTER JOIN . . . With a twist...

Status
Not open for further replies.

imstillatwork

IS-IT--Management
Sep 26, 2001
1,605
US
Hello,
I have a query I can't figure out.
3 tables:

1)tblUsers
2)tblCars
3)tblPics

One USERS can have many CARS, on CARcan have many PICS.
I want to make a search.

As is right now, I select the USER and CAR info that is needed. The results are looped over, displaying each car.

During each loop, I run another query that looks up ONE PIC from the CAR that will be displayed.

so this means if there are 10 cars returned per page (there are at least that) the getPics Query runs 10 times to show the page. talk about inefficient.

HOW CAN I combine all three tables into one query so that..

all the USER information is selected, all the CAR information is selected, and ONE pic of each car is selected....if I do an left outer, then i get repeated results because I am displaying in CARS, and there can be many pics each car. it is OK if this happens with USERS, i want the user repeated for every car that he has.

MAKE ANY SENSE?

thanks
Kevin

 
they MySQL guys gave me some things to try using MAX()
I have yet to try it, but it sounds promising. The problem is, I just don't know what is avavilable to use for more advanced queries.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top