Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL query involving linking table

0 views
Skip to first unread message

Lloyd Churches

unread,
Oct 29, 2002, 12:36:15 AM10/29/02
to
Hi
I need someone to create a complex SQL query.

I have the following tables
Vehicles, Accessories and AccLinking

The relevant fields are in
Vehicles: id, name, status
Accessories: id, name, status
AccLinking: id, accessoryid, vehicleid

Status is an integer with possible values of 1 to 6
accessoryid field represents id in Accessories table
vehicleid field represents id in Vehicles table

Ok. So now I need a list of vehicles (id, name) where status=6
and also where ALL the linked accessories have status=6
If a vechicle does not have any accessories then that should be included in
the list. So if any linked accessories do not have status=6 then the vehicle
should not be in the list.

Is there some simpler method of getting this list without nesting queries
heaps of times.

If you could figure this out and present it in an ASP page that would be
great!

/Lloyd


0 new messages