Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 61

A core SQL statement, SELECT retrieves data from one or more tables or other sources of row set data such as views or table-valued functions.

4
votes
which are aliased and some of which are not like so: SELECT tbl1.col1 AS column1 , tbl1.anothercolumn AS column2 , tbl1.column3 AS column3 , tbl2.somevalue AS column4 …
answered Apr 10 '18 by David Spillett
3
votes
SELECT * FROM table WHERE id IN ('x', 'y') AND (id='x' OR NOT EXISTS(SELECT id FROM table WHERE id='x')) should do the trick (caveat: I'm an MSSQL guy and haven't tried that in mySQL, but I …
answered Sep 6 '13 by David Spillett
7
votes
suggested as the way the code reads makes your intentions more obvious, you can also do: SELECT TOP 1 t1.id-1 FROM yourtable t1 LEFT OUTER JOIN yourtable t2 ON t2.id=t1.id-1 -- will …
answered Sep 17 '13 by David Spillett
1
vote
: select Column1 = dbo.YeyOrNay(Something, 2, SomethingElse, 1, AnotherThing, 1, 2), Column2 = dbo.YeyOrNay(Something, 3, SomethingElse, 0, AnotherThing, 2, 3), ... or select … Column1 = dbo.Col1Func(Something, SomethingElse, AnotherThing), Column2 = dbo.col2Func(Something, SomethingElse, AnotherThing), ... but while that makes the SELECT neater you might be reducing the …
answered Aug 27 '14 by David Spillett
1
vote
in all the tables as follows would work: SELECT ac.carID, ac.type, ac.commonAttribute1, ac.commonAttribute2 , ct.specialAttributeA , ca.specialAttributeB , cb.specialAttributeC FROM … SELECT. If a non-common attribute can appear in more than on of the sub-classes then change the definition for that output column to something like ca.specialAttributeD, cb.specialAttributeD AS …
answered May 6 '16 by David Spillett
2
votes
With SQL server (and, I suspect, pretty much everything else) querying for a range will be more efficient than querying for many individual rows, even when working locally. The range query will likely …
answered Jun 10 '14 by David Spillett
0
votes
You should make sure you have an index where reg_date is the first item covered, otherwise the query will table-scan the whole lot (an index on reg_date can be used for the limiting WHERE clause to re …
answered Mar 25 '13 by David Spillett
1
vote
Replace SUM(credit) with SUM(COALESCE(credit,0)) or SUM(ISNULL(credit,0)). You don't say what database you are using, so you may not have both the above functions available. If you have both, see you …
answered Jan 14 '14 by David Spillett
0
votes
That sounds like it is using an inappropriate query plan. There are two obvious paths this query could take and it is presumably deciding between them depending on the values of @row_offset and @row_c …
answered Sep 16 '14 by David Spillett