Writing an SQL query to SELECT item from the following table

Go To StackoverFlow.com

0

I am having a really hard time writing a SELECT query to get a hold of the data in the following table...

Here is a picture of the table...

http://i44.tinypic.com/29dxx81.png

I am trying to display the names of the parts (pname) for all item parts that have a quantity larger than 10... However, the quantity seems to appear only when the submenu is expanded, and I am having trouble SELECT'ing it...

Thanks

2012-04-04 22:50
by CSoverIT


0

Have you tried:

SELECT pname from [TableName] WHERE quantity >= 10

EDIT:

SELECT pname from Parts 
INNER JOIN Shipments
ON Parts.ForeignKey = Shipments.ForeignKey
WHERE quantity >= 10
2012-04-04 22:57
by Mausimo
Yes that DOESNT work. ... I know how to write basic SQL... this requires more then a simple SELECT x FROM y WHERE z < 10.. - CSoverIT 2012-04-04 22:58
what program is the image from? I have not seen a record that expands before.. is that linked data to another table - Mausimo 2012-04-04 22:59
The image is from ACCESS. Yes there is a table called Shipments that has a quantity column (without having to expand) .... how would I write the query asking to evaluate data from an table B to SELECT info from table A - CSoverIT 2012-04-04 23:00
What field is the relating field/foreign key. You would do a inner join. - Mausimo 2012-04-04 23:04
wouldn't something like this work... SELECT pname FROM Parts WHERE quantity IN( SELECT quantity FROM shipments > 10); ??? I tried it and it doesn't work, and I feel like i'm close... I don't think I should be dealing with foreign keys or inner joins, I appreciate the info though... : - CSoverIT 2012-04-04 23:13
How does that Part relate to the Shipment. They have to be tied together. Else it wont just return random data. They need to be linked. Your asking for a part that is related to a shipment where quantity is >= 10. Does Shipments table have pnum in it - Mausimo 2012-04-04 23:14
THANK YOU:) That worked - CSoverIT 2012-04-04 23:19
No Problem. Make sure to check-mark my answer : - Mausimo 2012-04-04 23:20
Ads