MySQL join inside subquery -
i have this:
# tab1 = company # tab2 = forms # tab3 = filled forms each company enabled it. # search companies pending/empty forms. # company #1 has 3 forms, filled, not listed; # company #2 has form 2 , 3, form 2 filled, listed; # company #3 has not form filled, listed; select company.* tab1 company ( select true tab2 forms # join compatible company forms results/fills. # itll join company.id (that here not exists) , forms.id (that exists) left join tab3 fills on fills.id_tab1 = company.id , fills.id_tab2 = forms.id # itll filter forms company have. # , accept if none result found, mean "pending fill" on company. # need that. find_in_set(forms.id, company.id_forms) , fills.id null )
and unknown column tab1.id
.
how solve it?
i need have access tab1
columns inside of inner of subquery.
update #1 - live sample: http://sqlfiddle.com/#!2/20aa5/3
try code, logic same
select tab1.* tab1 inner join tab3 on tab3.id_tab1 = tab1.id .....
Comments
Post a Comment