开发者

Select query in SQL

I have a very curious question. We have query to select records from table based on some 开发者_运维技巧condition. In general the syntax for the query is as below

SELECT * FROM TABLENAME WHERE COLUMNNAME='VALUE';

Now the question is that will this query will work if we interchange the position of COLUMNNAME and 'VALUE'.


Yes, it will. =)

Why did you not just try?


Yes. The following will work:

SELECT * FROM TABLENAME WHERE 'VALUE' = COLUMNNAME;


In fact, in Oracle at least, you can do some twisted but somewhat useful things like:

select *
from tablename
where 'VALUE' in (field1, field2, field3)


You mean

SELECT * FROM TABLENAME WHERE 'VALUE' = COLUMNNAME;

I tested it, it works on MSSQL Servver 2008


 SELECT * FROM TABLENAME WHERE 'VALUE' = COLUMNNAME;

if write something like this.. it'll work for sure..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜