Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

SELECT and WHERE without FROM Expand / Collapse
Author
Message
Posted Wednesday, June 22, 2011 8:22 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, July 2, 2014 9:56 AM
Points: 229, Visits: 302
Comments posted to this topic are about the item SELECT and WHERE without FROM


Post #1130099
Posted Wednesday, June 22, 2011 8:23 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:54 AM
Points: 5,594, Visits: 24,978
Nice question on fundamentals .. thanks

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #1130100
Posted Wednesday, June 22, 2011 10:41 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 5:52 PM
Points: 2,270, Visits: 3,789
Good question. I got to know something.

Mohammed Moinudheen
Post #1130122
Posted Thursday, June 23, 2011 12:51 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 25, 2011 1:03 AM
Points: 3, Visits: 4
Very Good basic question !
Post #1130169
Posted Thursday, June 23, 2011 1:06 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:16 AM
Points: 1,632, Visits: 5,585
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!
Post #1130181
Posted Thursday, June 23, 2011 1:27 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:53 AM
Points: 2,502, Visits: 2,384
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.
Post #1130192
Posted Thursday, June 23, 2011 1:59 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, July 31, 2014 2:37 AM
Points: 289, Visits: 114
Interestingly, this gives ORA-00923 error - FROM keyword not found where expected in Oracle.
(Hence I got it wrong!)
Post #1130205
Posted Thursday, June 23, 2011 2:04 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, July 4, 2014 9:03 AM
Points: 1,415, Visits: 796
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...
Post #1130207
Posted Thursday, June 23, 2011 2:28 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 6:19 AM
Points: 3,917, Visits: 5,109
Having worked with MSSQL, Oracle, Db2, Sybase and Informix databases, the only ones this command will work on is MSSQL and Sybase.
All the others require a FROM clause with a SELECT


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1130215
Posted Thursday, June 23, 2011 2:58 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 12:27 AM
Points: 1,101, Visits: 1,364
Nice question

Thanks
Post #1130230
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse