I am using access,and I have two tables:
point:
id,x,y
1 32432432 143423232
2 32432443 143423300
line:
id startPoint endPoint
1 1 2
Now, when I query the line,I want the returned table will contain both the x,y of the startPoint and the endPoint.
I have tried the join:
select line.*,point.x as x1,point.y as y1 from line as line join point as point on line.startPoint=point.id where line.id=1;
Then I can get the following result which only contain the startPoint.
id startPoint endPoint x1 y1
1 1 2 ......
Then how to retrive the endPoint while I want the result like this(x2 y2 is the coordinate of the endPoint):
id startPoint endPoint x1 y1 x2 y2
1 1 2 ......
I tried two join,but it does not work.
select line.*,point1.x as x1,point1.y as y1,point2.x as x2,point.y as y2 from line as line left join point1 as point on line.startPoint=point1.id left join point as point2 on line.endPoint=point2.id where line.id=1;
Access has weird syntax rules for multiple joins. You have to put them in parentheses like so.
Each additional join requires another left paren before the first table and a right paren after the second-to-last join.