sql - Join error: #1052 - Column 'TaskID' in field list is ambiguous -


trying join these 3 tables getting #1052 - column 'taskid' in field list ambiguous. please help

select p.projectcolor,timecardid,username,taskname,taskid,max (punch), totalhours,running,lastupdate  t_timecard e, t_task a, t_project p    e.taskid = a.taskid , p.projectid = a.projectid group punch  order punch desc; 

learn use explicit join syntax. problem caused because column same in both tables. yes, = suggests have same values, have explicit:

select p.projectcolor, timecardid, username, taskname, a.taskid,       max(punch), totalhours, running, lastupdate  t_timecard e join      t_task      on e.taskid = a.taskid join      t_project p      on p.projectid = a.projectid group  p.projectcolor, timecardid, username, taskname, a.taskid, totalhours, running, lastupdate  order max(punch) desc; 

your group by should mention columns not in aggregation columns.

by way, doubt query want. should ask question sample data , desired results, if case. don't edit question, because edits invalidate answers.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -