January 23, 2007 at 4:19 pm
Hi
You guys will probably find this pretty simple but a bit stuck.
I have a situation with three tables, I have a vehicles table has a relationship to a branch, however I want the history of branches the vehicle is assigned to as it move around so I have a table in the middle called branch assignment something like below...
Vehicle Table - uid,description
Branch Table - uid,branchname
BranchAssignentTable - ui,startdate,enddate,vehicleid,branchid
As you can see entries are place in branch assignment, when the assignment is comeplete enddate is populated and new record is created etc.
What I want to achieve is a select statement that gets the name of the branch with the vehiel details
ie.
Vehicledescrition,branchname
Any help appreciated.
Cheers
Mike
January 23, 2007 at 4:34 pm
SELECT v.Description, b.branchName
FROM branchAssignmentTable bat
INNER JOIN Vehicle v ON v.uid = bat.VehicleID
INNER JOIN Branch b on b.uid = bat.BranchID
January 24, 2007 at 4:13 am
Many thanks, told you it would be simple!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply