sql - Get data from both table, where data isn't common for this tables -


i have 2 tables

table jt1

name --- b c 

and table jt2

name --- b c d 

i need names both table, wich not common both tables, result must be

result ------ d 

this query, may there better solution this?

    select jt1.name  name  jt1     left join jt2     on jt1.name = jt2.name     jt2.name null      union      select jt2.name  name  jt2     left join jt1     on jt2.name = jt1.name     jt1.name null 

select    coalesce(jt1.name,  jt2.name) zname      jt1 full join jt2 on jt1.name = jt2.name     jt2.name null or jt1.name null   ; 

btw: naive solution faster:

select name (where not exists select 1         b b.name = a.name) union select name  b (where not exists select 1         a.name = b.name)    ; 

btw: purposely use union all here, because know 2 legs cannot have overlap, , removal of duplicates can omitted.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -