MySQL Find records that are not the same

1

Hello good day I have 2 tables that I show in the following image

I used this query

select a.rpu from costas a left join 
referencia b on b.rpu_ref = a.rpu where b.rpu_ref is null

To have the result of search that the table that rpu reference is not equal and I get this result

What I want to do is not just leave the rpu field but also the name field that is in the reference table.

Thanks

    
asked by Jose carlos 16.05.2018 в 18:33
source

2 answers

0

how about.

Have you tried with the DISTINCT clause?

SELECT DISTINCT field FROM table;

Greetings.

    
answered by 16.05.2018 в 23:51
0
  

It would be enough if you add a comma to your query after a.rpu and   column b.name already after everything else would be the same

select a.rpu, b.nombre from costas a left join 
referencia b on b.rpu_ref = a.rpu where b.rpu_ref is null;

The other order is maintained since the left join instruction is already

Now if you notice that you want values that are not repeated, add the operator DISTINCT to bring unique values

select distinct a.rpu, b.nombre from costas a left join 
    referencia b on b.rpu_ref = a.rpu where b.rpu_ref is null;
    
answered by 16.05.2018 в 18:42