MYSQL unknown column but column exists the varchar is timestamp

Here below the code is working

 SET @row := 0;
SELECT CONCAT(@row := @row + 1,' ',ui.firstname, ui.mname, ui.lastname) as 'FullName',
d.survey_at_what_blh, ui.status, ui.nature_of_work, ui.level, ui.course_or_section
FROM (select distinct survey_at_what_blh, userid from daily_report) d INNER JOIN userinfo ui ON d.userid = ui.id    

but when I add the d.date_opened like this

 SET @row := 0;
SELECT CONCAT(@row := @row + 1,' ',ui.firstname, ui.mname, ui.lastname) as 'FullName',
d.survey_at_what_blh, ui.status, ui.nature_of_work, ui.level, ui.course_or_section,  d.date_opened
FROM (select distinct survey_at_what_blh, userid from daily_report) d INNER JOIN userinfo ui ON d.userid = ui.id  

its displaying “Unknown Column ‘d.date_opened” in ‘field list’ but the column does exist here is the image of my column. Why is it not displaying? Can you guys give me a clue or hint on what i do wrong

Click this to view my database

Answer

You miss date_opened in here:

SET @row := 0; SELECT CONCAT(@row := @row + 1,’ ‘,ui.firstname, ui.mname, ui.lastname) as ‘FullName’, d.survey_at_what_blh, ui.status, ui.nature_of_work, ui.level, ui.course_or_section, d.date_opened FROM (select distinct survey_at_what_blh, userid, date_opened from daily_report) d INNER JOIN userinfo ui ON d.userid = ui.id

Leave a Reply

Your email address will not be published. Required fields are marked *