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 |
|
knudmt
Starting Member
12 Posts |
Posted - 2010-04-21 : 23:29:25
|
| Hello I am new to the forum and a beginner with SQL. I have an Internet programming assignment that is on the brink of completion. Problem is that I have to retrieve some info from the DB in a tricky way.here are the two tables:[tblPaths]PK PathIDpoiAIDpoiBID-------------------[tblPointOfInterest]PK IDGPSLatGPSLon-------------------I am trying to retrieve the GPSLat and GPSLon for poiAID and poiBID.the statement that should work but doesnt is this:SELECT tblPaths.poiAID, tblPaths.poiBID, tblPointOfInterest.GPSLat, tblPointOfInterest.GPSLonAS myLocationsFROM tblPaths, tblPointOfInterestWHERE tblPaths.poiAID = tblPointOfInterest.ID AND tblPaths.poiBID = tblPointOfInterest.IDI get no output. However when I use the OR operator I get some output. What is the problem?? I am beating my head against the wall here! I have a feeling it has to do with both poi IDs pointing to one ID. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-21 : 23:38:49
|
| [code]SELECT p.poiAID, p.poiBID, a.GPSLat, a.GPSLon,b.GPSLat, b.GPSLonAS myLocationsFROM tblPaths pJOIN tblPointOfInterest aON p.poiAID = a.ID JOIN tblPointOfInterest bON p.poiBID = b.ID[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
knudmt
Starting Member
12 Posts |
Posted - 2010-04-22 : 01:19:31
|
| WOW you are my new HERO!That worked wonderfully!I never thought of using two joins. Brilliant. You have no idea how much you have increased my knowledge level as well as saved my butt on this project! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-22 : 04:57:21
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|