This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » SQL and Databases » Can someone please help me with a SQL problem?
Reply

Can someone please help me with a SQL problem?

steve wang
Member



Since: 02 May 2009
Posts: 1
Posted 03 May 2009 00:19:07

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

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
Alan C
Total freaking Member



Since: 04 May 2006
Posts: 473
Replied 07 May 2009 12:04:43
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

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency