Last post Aug 30, 2011 04:17 AM by Taonias
Aug 30, 2011 03:26 AM|Taonias|LINK
I have 2 tables linked together with a many to many relationship and i need to have a stored procedure that will return one row of the 1st table and a count of the rows of the link table that contain the id of that 1st table.
Table1: id, description
LinkTable: table1Id, table2Id
Table2: id, description
I need to return from the stored procedure the select * from table 1 where id = 1 and also the select count(table1id) from LinkTable where table1id = 1
Can this be done?
Aug 30, 2011 03:46 AM|frez|LINK
select t1.id, t1.description, count(t2.id)
from t1 inner join t2
group by t1.id, t1.description
Aug 30, 2011 04:17 AM|Taonias|LINK