第一次使用Excel2007的Microsoft Query遇到的问题及解决:别名的使用

如果数据源是MsSql,则别名用[]括起来。

如:

SELECT  s.id as [ID],realname as [学生名字],workplacename as [校区],w.id as [校区ID],companyid as [分公司ID],s.create_time as [发生时间] from students s
left join offices o on s.currentplace=o.ID
left join workplaces w on o.workplaceid=w.id
where w.id in ('86')
order by w.id,s.create_time

如果数据源是MySql,则别名什么都不加。

如:

SELECT studentcode as ID,studentname as 学生名字,XDschoolshortname as 校区,XDschoolid as 校区ID,branchID as 分公司ID,InsertTime as 发生时间 FROM `StudentSearch`
where xdschoolID in ('303')
order by XDschoolid,InsertTime

原文地址:https://www.cnblogs.com/thomaswang/p/2043112.html