Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
StealthRider
Starting Member
13 Posts |
Posted - 2009-05-21 : 11:59:15
|
| I have created 3 tables:Fruit, Price, GrowsFruit:ItemColorPrice:ItemCostGrows:ItemLocationThe Query should result in:Items thats Red, That Cost 4.00, That Grows in SCThis is my code:SELECT ItemFROM Fruit, Price, GrowsWHERE Color = Red, Cost = 4.00, Location = SCError:Msg 102, Level 15, State 1, Line 3Incorrect syntax near ','. |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-05-21 : 12:35:45
|
| You should use joins not FROM Fruit, Price, Growsand in your where clause, replace the ','s with 'and'WHERE Color = Red and Cost = 4.00 and Location = SCJim |
 |
|
|
StealthRider
Starting Member
13 Posts |
Posted - 2009-05-21 : 12:44:28
|
| OK, I tried this:SELECT Itemjoin Fruit, Price, GrowsWHERE Color = Red and Cost = 4.00 and Location = SCError:Msg 156, Level 15, State 1, Line 2Incorrect syntax near the keyword 'join'. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-05-21 : 13:00:50
|
| You could look up the JOIN clause in Books On Line. Or go to W3 schools, they're great places to start learning SQL ServerJim |
 |
|
|
StealthRider
Starting Member
13 Posts |
Posted - 2009-05-21 : 14:26:42
|
| Thanks, looking over that now, still not really sure how to do this, but I guess it try, try, try, til you get it right. Hhahahahahaha |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-05-21 : 15:32:12
|
| Try, try, try and then give us what you got, and get more help as you need it. People are very good here and quite ready to help those willing to help themselves.Good Luck!Jim |
 |
|
|
StealthRider
Starting Member
13 Posts |
Posted - 2009-05-21 : 22:40:40
|
| OK, With a lil help I got it to work but I'm not 1005 sure what the code is doing so let me try to explain and someone please correct me if I'm wrong:SELECT p.Item = <B>Selecting the Price Item</B>FROM Fruit f = Saying from the Friut which f = fruitinner join Price p = ???????????? on f.item = p.item = Say Fruit Item = Price Iteminner join Grows g = ???????????? on p.item = g.item = Price Item = Grow ItemsWHERE Color = 'Red' AND Cost = '4.00' AND Location = 'SC'= The Information we are pulling out the tablesCan some help me Understand Inner JoinThanks |
 |
|
|
|
|
|
|
|