Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
irmorteza
Starting Member
8 Posts |
Posted - 2010-08-23 : 10:14:12
|
Hi I used cursor loop , and in each loop do select. but this selects are seperates from each other and "union statement" not work.my question is how can i combines select results in one in this situation .best regard. mortezaDECLARE @idBook int -- used for file name DECLARE db_cursor CURSOR FOR SELECT idFROM BookWHERE (idMember = 5)OPEN db_cursor FETCH NEXT FROM db_cursor INTO @idBook WHILE @@FETCH_STATUS = 0 BEGIN SELECT @idBook as idBook, tb1.id, member.username, type.type, tb1.budget FROM tb1 INNER JOIN type ON tb1.idType = type.id INNER JOIN member ON tb1.idMember = member.id WHERE (tb1.active = 0) AND (tb1.idBook = @idBook) FETCH NEXT FROM db_cursor INTO @idBook END CLOSE db_cursor DEALLOCATE db_cursor |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-23 : 10:27:20
|
[code]SELECT b.id AS idBook, t.id, m.username, y.[type], t.budgetFROM Book AS bINNER JOIN tb1 AS t ON t.idBook = b.id AND t.active = 0INNER JOIN [Type] AS y ON y.id = t.idTypeINNER JOIN member AS m ON m.id = t.idMemberWHERE b.idMember = 5[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
irmorteza
Starting Member
8 Posts |
Posted - 2010-08-23 : 11:15:40
|
thancks Pesoi did this before but return nothing in your way |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-23 : 14:27:46
|
Then nothing is returned with your cursor code either? N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|