开发者

Select query in SQL

开发者 https://www.devze.com 2023-01-13 09:42 出处:网络
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

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

精彩评论

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