Back to Top

difference between right join and normal data

Difference between Right join and simple Join 

The SQL JOIN is used to join or combining of the rows from the one or more tables. This can be on the basis of the common field between these two tables. so piking the common field from these two tables can only be allow you to use join clause in SQL.

There are following difference between Right and Inner join .


Solution1: Example of Right Join 

select distinct R_id, m_id, m_en as MemberName,mo_en as MotherName,
 fo_en as FatherName,U_ID,a.r_idas Relation, m_age as Age,
 CONVERT(varchar(15), m_dob, 103) as DOB
 ,case when gendertype=1 then 'Male' else case when gendertype=2 then 'Female' end end as Gender,
 gendertype,rel.RS_Name_EN as RelationText,
 nationality,MobileNumber from  TABLE_C c
 right join  TABLE_A a on   a.R_id=c.rationcardid and a.member_name_en=c.accountholdername joinTABLE_R rel
 on a.relationship_rs_code=rel.[RS_Code]

 where   a.IsDeleted=0  and R_id=7507089 order by m_id


-----------------------------------------------------------------

Solution2: Example of simple Join or inner join

select distinct R_id, m_id, m_enas MemberName,mo_enas MotherName,
 fo_enas FatherName,U_ID,a.r_idas Relation,m_age as Age,
 CONVERT(varchar(15), m_dob, 103) as DOB
 ,case when gendertype=1 then 'Male' else case when gendertype=2 then 'Female' end end as Gender, gendertype,rel.RS_Name_EN as RelationText,
 nationality,MobileNumber from    TABLE_A a join TABLE_Rrel
 on a.relationship_rs_code=rel.[RS_Code]  join
 TABLE_C c on a.R_id=c.rationcardid

 where  a.IsDeleted=0  and R_id=7507089 order by m_id

0comments

Post a Comment