sql - How to fetch data from two table? -
i have 2 tables table1
& table2
table1
s.no|uniquenumber | assigned_to 1. | s123 | tom 2. | s234 | harry 3. | s345 | tom
table2
s.no|uniquenumber | status 1. | s123 | approve 2. | s234 | approve 3. | s345 | reject
i want fetch uniquenumber
status
approve
& assigned
tom
. trying use union
where
clause. think union
doesn't work here. how achieve this?
you must use join:
select table1.uniquenumber, status, assigned_to table1 inner join table2 on table1.uniquenumber = table2.uniquenumber status = 'approve' , assigned_to ='tom'
Comments
Post a Comment