Friday, March 1, 2013

Sql Server Login

If I have the following records in a table:

Parent     Child
1 2 <--
2 1 <--
3 2
3 4
 
Result:
SELECT a.parent, a.child
FROM table1 a
INNER JOIN table1 b ON (b.child=a.parent and a.child = b.parent)
 
 
Question2
table had 
same table but two foreign keys
 

SELECT
t31.chvstopname,t31.fltStopLat,t31.fltStopLng,
t32.chvstopname,t32.fltStopLat,t32.fltStopLng,
inbSourceStopID,inbDestinationStopID,*
FROM   tblsluglines t2
LEFT   JOIN tblslugstop t31 ON t31.inbstopID = t2.inbSourcestopID
LEFT   JOIN tblslugstop t32 ON t32.inbstopID = t2.inbDestinationstopID
where t31.fltStopLat =11.026629734163739  and t31.fltStopLng =76.906185150146484 

 
 
 
 
 
 

No comments:

Post a Comment