Forums

This topic is locked

Can someone please help me with a SQL problem?

Posted 03 May 2009 00:19:07
1
has voted
03 May 2009 00:19:07 steve wang posted:
Hi guys, i'm very new to this type of forum.
I have a SQL assignment for a class, and I don't have enough resources to help me figure out some problems, so hopefully I can get some insight here.

These are the tables for the question: (underlined is primary key, italicized is foreign key)
Customer (CustID, CustName, AnnualRevenue, CustType)
Shipment (ShipmentNumber, CustID, Weight, TruckID, DestinationCity, ShipDate)
Truck (TruckID, DriverName)
City(CityName, Population)

question: List the names of drivers who have delivered shipments for customers with annual revenue
over $30 million to cities with populations over 2 million?

this is what i have so far from it:

SELECT Truck.DriverName
FROM Truck, Customer, City
WHERE Customer.AnnualRevenue>30,000,000
AND City.Population>2,000,000

I think i have to join the three tables together with another "AND", but I am very lost on how to do that. Can anyone help? I would appreciate it greatly. Thanks

Replies

Replied 07 May 2009 12:04:43
07 May 2009 12:04:43 Alan C replied:
first establish what JOIN does, it joins tables together. Begin with an easy example and try it using phpmyadmin, then you will be able to pull things out of other tables using those foreign keys, next check out AND - it does something different. You're on the right lines asking for guidance, assignments are to make you research the topic and learn by problem solving :-)

also check this . . .

www.catb.org/~esr/faqs/smart-questions.html#homework

Reply to this topic