473,396 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to constrain a query to return 1 or 0 rows (or >1 or 0 rows)

This is probably a stupid question, but ...

I'd like to be able to take an existing query and modify it to return a
single row if that's what the base query returns, and 0 rows if the
base query returns multiple rows. Similarly, I'd like to also modify
it to return multiple rows if that's what the base query returns, and 0
rows if the base query return a single row.

What's a good way to do this?

Thanks,
Kevin Murphy
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
1 1114
On Fri, Sep 10, 2004 at 17:39:31 -0400,
Kevin Murphy <mu****@genome.chop.edu> wrote:
This is probably a stupid question, but ...

I'd like to be able to take an existing query and modify it to return a
single row if that's what the base query returns, and 0 rows if the
base query returns multiple rows. Similarly, I'd like to also modify
it to return multiple rows if that's what the base query returns, and 0
rows if the base query return a single row.

What's a good way to do this?


SELECT * FROM whatever HAVING count(*) < 1;

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: helpful sql | last post by:
Hi all, I am using an HTML table control on my ASP.Net page. Now I need to change this table so that columns become rows and rows become column. Since the table is very complex with many controls...
1
by: Eric Goforth | last post by:
Hello, When I remove MYTABLE5.HAPPYCAPACITY from the SELECT clauses of the following query, the number of rows returned drops from 28 to 24. If I put it back in it goes back up to 28. Any idea...
1
by: Phil Endecott | last post by:
Dear Postgresql experts, According to the documentation for MOVE, it returns the number of rows that it has moved over. It seems to me that this is true for MOVE FORWARD n, but not for MOVE...
7
by: MLH | last post by:
?dcount("","qryOwnrsDueITSwMissingAddr") when run in the immediate window return a number greater than the number of rows that display when the saved query is run - opening in the database window?...
1
by: gus1339 | last post by:
Does anyone know how to do this? a query to show only rows where joined fields from both table are NOT equal Thanks!
6
khalidbaloch
by: khalidbaloch | last post by:
i want to show on page the messege that say there is currently no item when a mysql query return no record instead of blank page .. i hope this is not a big issue and will be resolved in first reply...
1
by: sudheerk | last post by:
How to split the query results into different rows
7
by: kunku | last post by:
Hi, I am using a query "Select SUM(Amount) from tblAccount where TransactionID=' "+textBox1.Text+" ' "; in my C# project this query return dataset.Tables.Rows.Count =1 eventhough there...
2
by: kkshansid | last post by:
same query return rows in mysql but not on php page while($rs = mysql_fetch_array($sql2)) { $town=$rs; $q="select * from institute where address like '%".$town."%'";//this query //echo $town;...
3
by: pbenson | last post by:
I'm a novice at Access and am having trouble with a Not Like query. I'm trying to remove rows with the term "Accrual" from a table. I know there are 16 rows that have the term Accrual, but when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.