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 |
|
Osama
Starting Member
5 Posts |
Posted - 2008-10-08 : 07:29:32
|
Hi guys, remember ,, there are no stupid questions there is only easy ones and this one is an easy question i have 2 tables 1st table UsersAndTenders contains Username and TenderNumber (2 columns) -- each username is assigned 1 or MORE tendernumber .2snd table TenderInfo contains general info on Tenders and it has the column TenderNumber. (6 columns including TenderNumber) what i want to do is to select all the columns from the 2nd table TenderInfo where UsersAndTenders.tendernumber is assigned to User.Identity.Name in the table UsersAndTenders.here are the tables as shown in the dataset.xsd filehttp://docs.google.com/Doc?id=ddkz74cx_44d592d8gc The problem is that in the 1st table UsersAndTenders there could be more than one row containing the same user name for different tender numbers.I hope i was clear enough for you to help me out on this. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-08 : 07:42:27
|
do you mean this>SELECT t1.* FROM TenderInfo t1JOIN (SELECT TenderNumberFROM UsersANDTenders GROUP BY TenderNumber)uON u.TenderNumber=t1.TenderNumber |
 |
|
|
Osama
Starting Member
5 Posts |
Posted - 2008-10-08 : 07:56:37
|
quote: Originally posted by visakh16 do you mean this>SELECT t1.* FROM TenderInfo t1JOIN (SELECT TenderNumberFROM UsersANDTenders GROUP BY TenderNumber)uON u.TenderNumber=t1.TenderNumber
yes but its missing the WHERE condition .. This will get all the info from TenderInfo Table for the tenders who are in the UsersAndTenders Table. so far so good.. but i need one more condition that says (( get only the TenderNumber from UsersAndTenders Where Username =@un )) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-08 : 07:59:30
|
| cant you just tweak the query provided to get what you want? |
 |
|
|
Osama
Starting Member
5 Posts |
Posted - 2008-10-08 : 08:03:25
|
quote: Originally posted by visakh16 cant you just tweak the query provided to get what you want?
its not just adding the WHERE .. i would have done it if it was so.. you see what i want is this : When the user : newuser logs in , i want to show a table with information about all the tenders he is registered for in the UsersAndTenders .. so i want info from TenderInfo for all the Tenders registered for That user. |
 |
|
|
Osama
Starting Member
5 Posts |
Posted - 2008-10-08 : 08:05:17
|
| Its ok .. i got it and you was correct.. sorry :P just added the WHERE condition in the second Select and it worked... thanks a lot. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-08 : 08:14:45
|
quote: Originally posted by Osama Its ok .. i got it and you was correct.. sorry :P just added the WHERE condition in the second Select and it worked... thanks a lot.
No worries. wanted you to spot out that didnt want to spoonfeed you. |
 |
|
|
|
|
|