Solved

Is there a way to Select none in SQL?

Posted on 2009-05-04
4
2,279 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
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.

747 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

14 Experts available now in Live!

Get 1:1 Help Now