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 |
bkbinani
Starting Member
15 Posts |
Posted - 2011-12-22 : 08:31:04
|
Dear Experts,i wish to connect master table with transaction with condition thattranscation table id value <> 0. when Zero it sud return *** as value.Since My Table may have id = 0 or 1,2,5,8,99 etcI was trying as under but not suceess.Plz Help.-- dat_itm_detail --> Transaction Table-- mst_led --> Master-- dat_itm_detail.iagent_id may have 0 value means no records in master-- but valid transaction without AGENT.select mst_led.cled_name, dat_itm_detail.uitem_trnid, dat_itm_detail.iagent_idfrom dat_itm_detailjoin mst_led on mst_led.iled_autono = iagent_idwhere dat_itm_detail.ivch_type=1 Executing this skip few records where agent_id=0. But I wish to have all those records too.Plz guide me. TIA |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-12-22 : 09:09:42
|
Try using a left join as in-- dat_itm_detail --> Transaction Table-- mst_led --> Master-- dat_itm_detail.iagent_id may have 0 value means no records in master-- but valid transaction without AGENT.select mst_led.cled_name, dat_itm_detail.uitem_trnid, dat_itm_detail.iagent_idfrom dat_itm_detailLEFT join mst_led on mst_led.iled_autono = iagent_idwhere dat_itm_detail.ivch_type=1 |
 |
|
bkbinani
Starting Member
15 Posts |
Posted - 2011-12-26 : 01:34:01
|
Thanx Sir.It worked. Very Nice & Cool. Hope 2 c u again. |
 |
|
|
|
|