Solved

Is there a way to Select none in SQL?

Posted on 2009-05-04
4
2,316 Views
Last Modified: 2012-05-06
Hello,

I know * selects all, so is there a similar way to SELECT none in SQL?

Thanks in advance,


0
Comment
Question by:dschrishuhn
4 Comments
 
LVL 51

Accepted Solution

by:
Mark Wills earned 100 total points
ID: 24295896
Interesting question....

You can select <column list> from <datasource> where 1 = 2

which will give you all the <column list> but with NULL entires.

Is that what you mean ?

You can also :

select NULL from <datasource>

but in Access think it is the same as if nothing was selected - but is handy in SQL Server to test "if exists" type conditions.
0
 
LVL 6

Assisted Solution

by:mvgeertruyen
mvgeertruyen earned 75 total points
ID: 24295903
* selects all columns... Why would you want to run a query that doesn't return columns?
If you just want to return no rows you can do that with select top 0 *
0
 
LVL 7

Assisted Solution

by:coffeeshop
coffeeshop earned 75 total points
ID: 24296004
Or

SELECT 1 AS Dummy FROM <table>

to get all rows but no useful information about it.
0
 

Author Closing Comment

by:dschrishuhn
ID: 31577572
Found a workaround.  Thanks for your time and suggestions
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Date Range Syntax Access 2003 10 53
SQL query 4 46
Strange msg in the SSMS pane 13 47
Updating a table from a temp table 4 26
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now