关于简单的一条sql查询语句
select x.tno,x.score as xscore,y.score as yscore from evaluate as x,evaluate as y where (x.score>y.score) and (y.tno='14')
如上查询语句为表的自身连接查询语句,但是sql报错了,内容为sql命令未正确结束,为什么?求高手指教!
[解决办法]
测试了一下,没问题啊,是不是不仅仅只有这语句?
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-08-06 07:47:06
-- Version:
-- Microsoft SQL Server 2014 (CTP1) - 11.0.9120.5 (X64)
--Jun 10 2013 20:09:10
--Copyright (c) Microsoft Corporation
--Enterprise Evaluation Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------
--> 测试数据:[evaluate]
if object_id('[evaluate]') is not null drop table [evaluate]
go
create table [evaluate]([tno] int,[score] int)
insert [evaluate]
select 1,123 union all
select 14,12312 union all
select 2,452314
--------------开始查询--------------------------
select x.tno,x.score as xscore,y.score as yscore from evaluate as x,evaluate as y where (x.score>y.score) and (y.tno='14')
----------------结果----------------------------
/*
tno xscore yscore
----------- ----------- -----------
2 452314 12312
*/
--没有问题啊,有可能是全角空格造成的,试试下面的
select x.tno,x.score as xscore,y.score as yscore
from evaluate as x,evaluate as y
where x.score>y.score and y.tno='14'
x.score AS xscore ,
y.score AS yscore
FROM evaluate x , --把as 去掉
evaluate y
WHERE ( x.score > y.score )
AND ( y.tno = '14' )