Search code examples
mysqlsqlleft-joinright-join

In Mysql, Left/right join gets result same column twice


I have a very basic problem in mySQL query. My code is that

select * 
from member 
left join cupwinner 
on member.mid=cupwinner.mid; 

As a result, my final table has twice "mid" column. Table has these columns:

MID, name, Mtype, Debt, MID, Year, Description.

But i want this table by not using member.mid, name, mtype, debt, year, description.

MID, Name, Mtype, Debt, Year, Description 

Is there any solution? By the way, sorry for my English.


Solution

  • As a general rule it is best to list all the columns you want explicitly in the select. But, you can use this short-cut:

    Select *
    From member m left join
         cupwinner cw
         using (mid);