« first day (2181 days earlier)      last day (477 days later) » 

jjj
3:40 PM
Hi people, could anyone help me with a newbie error, namely 1054 Unknown column in field list?
select dve_id, dve_usr_id, dve_devicekey, ifnull(g.download.dnld_time, g.download_mat.dm_created), g.download_source.ds_name
from g.device
left join g.download on g.download.dnld_id = g.device.dve_dnld_id
left join g.download_mat as id on id.dm_os_id = g.device.dve_devicekey
left join g.download_source on g.download_source.ds_id = g.download.dnld_ds_id
left join g.download_mat as dt on dt.dm_created = g.download.dnld_time
Whats wrong here? I am new to mysql and I really have no idea how should I proceed..
Oh, and the unknown column is: g.download_mat.dm_created
 
4:07 PM
@jjj So g is your database/schema name?
@jjj It's because you aliased download_mat both times you joined it on
you want either dt.dm_created or id.dm_created
 
jjj
4:19 PM
Oh, thank you! I'll try that. Damn, sql seems so difficult sometimes :)
(or maybe all the time, if youre a noob)
 
@jjj haha, the learning curve isn't the worst, but it sure is intimidating at first
aliases do make queries confusing. I avoid them in general. In your case though, you're forced into it by needing to use the same table twice
maybe aliasing them as download_mat_id and download_mat_dt would read a bit better?
 
jjj
yes, probably. thanks!
 

« first day (2181 days earlier)      last day (477 days later) »