I have a problem while trying left join one column from one table, because i need 2 columns consult the name by the id
I keep trying and sometimes get null results or the same in origin and destination, how is it the correct way to have the correct result
i have this MYSQL QUERY:
SELECT ORDER.id, ORDER.responsable, ORDER.date, ORDER.state, LOCATION.name as destination, LOCATION.name as origin FROM
ORDER
LEFT JOIN LOCATION ON destination = LOCATION.id;
With this result:
destination | origin |
---|---|
HOUSE | HOUSE |
HOUSE | HOUSE |
I expect something like this:
destination | origin |
---|---|
HOUSE | WORK |
HOUSE | WORK |
On DB is like this:
destination | origin |
---|---|
0 | 1 |
0 | 1 |
rodrigo cantu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.