sql - How to get rid of duplicates after combining 2 tables? -


i new sqlplus.i need rid of duplicates.that is, don't want combinations of 2 tables.

 select club.name club_name,    club.phone club_phone,    customer.firstname cust_name,   customer.phone cust_phone,  customer,club ; 

i want club names there phonenumbers , same customers(name , phone) different tables(club , customer).and not there combination.

i cannot use group have not used computation here

group club_name,cust_name; 

(ora-00979: not group expression).

please help.

you use union all

select club.name name,    club.phone phone,     'club' type club union select  customer.firstname,   customer.phone,   'customer' customer ; 

this customers , clubs respective phones.

i added column of "type" in case want identify wich table data came from. if don't need it, can remove it.

by removing column, means if have same record in both tables, not twice.

edit:

if want results in different columns, can either separate queries each table, or can union all, , return 4 columns, when referring customers, columns clubs null.

you this:

select club.name clubname,    club.phone clubphone,   null customername,   null customerphone club union select null,   null,   customer.firstname,   customer.phone customer ; 

see fiddle


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -