[英]MySql 5.6 Column level Query
I'm trying the following SQL in MySQL 5.6: 我正在MySQL 5.6中尝试以下SQL:
select Test=1 from ALL_FILES_INFO;
However I am getting an error. 但是我遇到一个错误。
Error Code: 1054. Unknown column 'Test' in 'field list' 错误代码:1054。“字段列表”中的未知列“测试”
it is some thing Like this 像这样的东西
Select Name,
Amount=(select Amount from EmployeeAmount where EmployeeName=Name)
from Employee;
The same code is running properly In Microsoft SQL Server. 相同的代码在Microsoft SQL Server中正常运行。
SQL Server has an alternate way of stating column aliases, this will as far as I can tell do the exact same thing and work on both MySQL and SQL Server; SQL Server有另一种陈述列别名的方式,据我所知,这完全相同,并且可以在MySQL和SQL Server上使用;
SELECT 1 AS Test from ALL_FILES_INFO;
SQLFiddle for SQL Server 用于SQL Server的SQLFiddle
SQLFiddle for MySQL 适用于MySQL的SQLFiddle
You'd be better off joining your tables than using your correlated subquery: 与使用相关的子查询相比,加入表会更好:
SELECT Employee.Name, EmployeeAmount.Amount
FROM Employee
JOIN EmployeeAmount ON EmployeeAmount.EmployeeName = Employee.Name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.