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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-01 : 09:02:58
|
| jane writes "There are 2 tables: A and BA has 2 fields: user_id, nameB has 1 field: name ( the name included name of Table A)Now, I need choose 5 random name from table B for each user_id of table A, and these 5 name should exclude the name of corresponse user_id of table A.select A.user_id,B.namefrom A , (select top 5 name from B order by newid()) Bwhere B.name not in (select name from A where user_id=A.user_id)but I get the same name for each user_id, I hope they should different result, How can I get this in sql statement?thanks" |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2002-03-01 : 09:02:58
|
| Check out these articles: http://www.sqlteam.com/FilterTopics.asp?TopicID=135 |
 |
|
|
|
|
|