June 22, 2011 at 8:22 pm
Comments posted to this topic are about the item SELECT and WHERE without FROM
June 22, 2011 at 8:23 pm
June 22, 2011 at 10:41 pm
Good question. I got to know something.
M&M
June 23, 2011 at 12:51 am
Very Good basic question !
June 23, 2011 at 1:06 am
I looked at the question, thought, "Surely this is obvious"--went and ran it in SSMS just to be sure I wasn't missing something. It was only when I came here I realised it was talking about the missing FROM clause! 🙂
June 23, 2011 at 1:27 am
If the condition of the WHERE clause validates to true then the result set is returned. If it does not, the result set is empty.
This is true only if you do not use COUNT(*):
select count(*) cnt
where 1 =0
One row is returned despite the WHERE condition is false.
June 23, 2011 at 1:59 am
Interestingly, this gives ORA-00923 error - FROM keyword not found where expected in Oracle.
(Hence I got it wrong!)
June 23, 2011 at 2:04 am
Geoff Langdon (6/23/2011)
Interestingly, this gives ORA-00923 error - FROM keyword not found where expected in Oracle.(Hence I got it wrong!)
Geoff how about:
1 select '123' as col1
2 from dual
3* where 1 =1
orhousin@BUSO> /
COL
---
123
I was expecting this question to have almost 100% correct answers...
June 23, 2011 at 2:28 am
This was removed by the editor as SPAM
June 23, 2011 at 2:58 am
Nice question
Thanks
June 23, 2011 at 3:14 am
Nice question, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 23, 2011 at 3:17 am
You don't even need the WHERE clause. I've just done an SSIS step where I needed a single row returned, but didn't care about the contents, so I used
SELECT 1
and it worked fine.
June 23, 2011 at 8:03 am
I'd have got it right had I not accidentally clicked Parse instead of Execute! :doze:
June 23, 2011 at 8:07 am
Nice question. It makes me smile to see "where 1 = 1" or "while 1 = 1" in code.
June 23, 2011 at 8:15 am
I'm enjoying the T-SQL questions this week!
Leonard
Madison, WI
Viewing 15 posts - 1 through 15 (of 28 total)
You must be logged in to reply to this topic. Login to reply