I've searched a lot but I still don't get it.
Here's my sample code
SELECT sp.testno, sp.companyid, st.*
FROM sponsor AS sp
LEFT JOIN
(
SELECT a.sponsorempno, (CASE WHEN t.companyid IS NULL OR t.companyid = '' THEN'aa' ELSE t.companyid END) agncy, a.controlno, a.tnpl, t.*
FROM applicant AS a
LEFT JOIN
test AS t
ON a.controlno = t.controlno
) AS st
ON sp.testno = st.testno
I still returns an error:
#1060 - Duplicate column name 'controlno'
Can somebody tell me what's wrong with the code?
a.controlnoexplicitly andt.controlnoimplicitly fromt.*. Assign an alias to at least one of columns (for example,... , a.controlno AS a_controlno, ...). Or replaceON a.controlno = t.controlnowithUSING (controlno)- these columns will be collapsed into one with the value taken from left table (a.controlno).