How to replace union by join in mysql -


select service_type service_type s union select service_type cust_service_type cs 

i want replace union joins. please let me know changes need made.

mysql not support full join it's impossible in mysql.

in other systems, use syntax:

select  distinct coalesce(service_type, cust_service_type)    service_type s full join         cust_service_type cs on      cs.service_type = s.service_type 

or

select  distinct service_type    service_type s full join         cust_service_type cs using   (service_type) 

for systems support join ... using

note union more efficient solution.

update:

if want fields both tables, use this:

select  *    service_type s union select  *    cust_service_type cs   service_type not in         (         select  service_type            service_type         ) 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -