C
ChrisG \(UK\)
My first post so be gentle with me )
I have an owner table
Id Name
1 Sid
2 Bill
3 Fred
This links through Owner_id to the Owned table
Id Owner_id type
1 1 1
2 2 2
3 3 1
4 3 2
Sid owns a type 1
Bill owns a type 2
Fred owns a type 1 and 2
I want to search for type 1 owners and have them returned plus an additional
column that shows if they also own a 2
Id Name type2
1 Sid NULL
3 Fred 2
In SQL Server following code works
SELECT owner.id, owner.name ,o2.type
FROM owner
INNER JOIN owned ON owner.id = owned.owner_id
left outer join owned o2 on owner.id=o2.owner_id and o2.type=2
Where owned.type=1
Access initially gives me this
SELECT owner.id, owner.name
FROM owner
INNER JOIN owned ON owner.id = owned.owner_id
WHERE (((owned.type)=1));
Then I add
left outer join on owned as o2 where o2.owner_id = owner.id and o2.type=2
And it complains.
Any help gratefully received.
Chris....
I have an owner table
Id Name
1 Sid
2 Bill
3 Fred
This links through Owner_id to the Owned table
Id Owner_id type
1 1 1
2 2 2
3 3 1
4 3 2
Sid owns a type 1
Bill owns a type 2
Fred owns a type 1 and 2
I want to search for type 1 owners and have them returned plus an additional
column that shows if they also own a 2
Id Name type2
1 Sid NULL
3 Fred 2
In SQL Server following code works
SELECT owner.id, owner.name ,o2.type
FROM owner
INNER JOIN owned ON owner.id = owned.owner_id
left outer join owned o2 on owner.id=o2.owner_id and o2.type=2
Where owned.type=1
Access initially gives me this
SELECT owner.id, owner.name
FROM owner
INNER JOIN owned ON owner.id = owned.owner_id
WHERE (((owned.type)=1));
Then I add
left outer join on owned as o2 where o2.owner_id = owner.id and o2.type=2
And it complains.
Any help gratefully received.
Chris....