开发者

SQl to select from multiple tables

开发者 https://www.devze.com 2022-12-22 14:13 出处:网络
I have two table emptable1(empid,status) emptable2(empid,week) i want to select all the empid whose status is 0 in emptable1 and from that list of empid i need to select empid whose week is 7 from th

I have two table emptable1(empid,status) emptable2(empid,week)

i want to select all the empid whose status is 0 in emptable1 and from that list of empid i need to select empid whose week is 7 from the开发者_运维知识库 table emptable2

Please help :-)


Not knowing your table structure in detail, but this ought to work:

SELECT  
    (fields)
FROM 
    dbo.emptable1 e1
INNER JOIN
    dbo.emptable2 e2 ON e1.empid = e2.empid
WHERE 
    e1.status = 0
    AND e2.week = 7


How about using join? Join the two, then do your logic implementation altogether.

0

精彩评论

暂无评论...
验证码 换一张
取 消