CodeLover
asked on
sql problem in a joint query
Hi, all
I am using an SQL query in my asp file. In table Order: OrderId, StartPlaceId, EndPlaceId (Both placeIds are foreign keys of table Place). In table Place: PlaceId, PlaceName.
select O.OrderId, P.Name, Po.Name from Order as O, Place as P, Place as Po where O.StartPlaceId = P.PlaceId and O.EndPlaceId = Po.PlaceId
But it doesn't work. Could you please help me out? Thanks.
I am using an SQL query in my asp file. In table Order: OrderId, StartPlaceId, EndPlaceId (Both placeIds are foreign keys of table Place). In table Place: PlaceId, PlaceName.
select O.OrderId, P.Name, Po.Name from Order as O, Place as P, Place as Po where O.StartPlaceId = P.PlaceId and O.EndPlaceId = Po.PlaceId
But it doesn't work. Could you please help me out? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually the experts here are giving suggessions in a guess. B'coz the question is not so clear.
The CodeLover has to say more here. First of all, codelover has to say, whether is it giving any error, or is it giving unexpected rows or is it not giving any row.
What is the error or message or display you are getting. We would go from there then.
The CodeLover has to say more here. First of all, codelover has to say, whether is it giving any error, or is it giving unexpected rows or is it not giving any row.
What is the error or message or display you are getting. We would go from there then.
No, ramani_gr, I was not guessing. The information is sufficient (assuming that it is correct), and the error is clear to see.
Now, i would write the query like this (SQL Server):
select O.OrderId, Ps.Name as StartPlace, Pe.Name As EndPlace
from Order as O
join Place as Ps
on Ps.PlaceId = O.StartPlaceId
join Place as Pe
on Pe.PlaceId = O.EndPlaceId
Now, if you don't use SQL Server, please indicate your db.
Cheers