Question : sql server stored procedure syntax question

I need to do the following:

1) Select  CompanyID From Companies (table) where username = my passed in username that i pass in.

2)Select  * from Vendors where companyId = ‘returned company from previous query’

Basicly i need the companyId returned from the first id so that i can use it to query the vendors table. How would i do so with one query?

Answer : sql server stored procedure syntax question

The alternate approach:
1:
2:
3:
4:
5:
6:
7:
8:
9:
Select v.*
From Vendors v 
Where Exists (
   Select Top 1 Null
   From Companies c   
   Where v.companyId = c.companyId
   And c.username = 'user name you pass in'
)
;
Random Solutions  
 
programming4us programming4us