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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 sql query

Author  Topic 

iceice
Starting Member

5 Posts

Posted - 2011-07-20 : 07:00:29
i want to query two tables. some example fields and data below:

call_req table (its main table)
--------------
id
refnum
summary
description
status

act_log table (its second table)
--------------
call_req_id
type (example: RE,TR,LOG,INIT,CL,...)
description

i want to query all rows in main table and if any id equal with call_req_id in second table (just 'RE' type) i want to see type description in RE type.
can you help me, thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-20 : 07:20:04
its just a simple left join like

SELECT cr.*,al.description
FROM call_req cr
LEFT JOIN act_log al
On al.call_req_id = cr.id
and al.type='RE'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

iceice
Starting Member

5 Posts

Posted - 2011-07-20 : 08:26:07
I tried this query. Its working.
Thank you.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-20 : 08:27:36
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -