加入多个选择的quires

时间:2017-10-15 16:07:46

标签: mysql mariadb

我有一个TABLE,我写的查询在小提琴上运行正常,但在实际服务器上实现时,我收到以下错误

1054 - 未知栏' t2.EmpName'在' on条款'

Fiddle是mysql 5.6,我正在运行ver 15.1 MariaDB

感谢您的帮助!这是我的疑问:

helper2

1 个答案:

答案 0 :(得分:0)

可能是你在sqlfiddle中的代码和你在服务器上使用的代码之间有一些区别 无论如何为了更好的易读性和避免错误我建议你更清楚地使用别名(特别是当你使用自我加入时)
当您需要时,请不要使用引号来使用列名来使用backctics:

  select
    t1.EmpName as Employee,
    t1.weekof as `Week Of`,
    t2.pph as `Previous PPH`,
    t1.pph as `Current PPH`,
    t1.quality as Quality
  from table1 t2
  join table1 t1 on t2.EmpName = t1.EmpName
  where t2.weekof = '9/11/2017' and t1.weekof = '9/18/2017'
  ;