MySQL Left Join more than once -


i have table this:

data:

id | state | more ----------------- 1  | 1     | ... 2  | 2     | ... 3  | 1     | ... 

and states:

id | state ---------- 1  | open 2  | closed 

if

select states.state data left join states on data.state = states.id 

i receive

state ----- open closed open 

so far good. trying (without success) is, if have table data this:

id | state | state2 | more -------------------------- 1  | 1     | 2      | ... 2  | 2     | 1      | ... 3  | 1     | 1      | ... 

how get:

state  | state 2 ---------------- open   | closed  closed | open open   | open 

select states.state, states2.state data left join states states on data.state = states.id left join states states2 on data.state2 = states2.id 

Comments

Popular posts from this blog

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

javascript - Create a stacked percentage column -