Wednesday, January 7, 2015

Query write by two query using distinct

Query write by two query using distinct :distinct means at a time not show same id more time
Suppose :
id 1 = patient one
id 1 = patient two
id 1 = patient three

If I use distinct :
id 1 = patient one
     = patient two
     = patient three




op_consultation
hr_employee


select distinct(reg_no)  from op_consultation  where CONSULT_BY = 'E011001000425'

select *from op_registration where reg_no='R011002000101'




select * from op_registration where reg_no in (select distinct(reg_no)  from op_consultation  where CONSULT_BY = 'E011001000425')

No comments:

Post a Comment