Re: Enforce value on select

2004-10-11 Thread Santino
SELECT nameColumn, otherColumn, count(*) as flag FROM theDatabase WHERE rowID = 1 group by rowID; or make a temp table with the IDs and then left join it with theDatabase and drop temp. Santino At 23:27 -0700 10-10-2004, John Mistler wrote: Good idea. liang le's answer almost got it, but I cou

Re: Enforce value on select

2004-10-11 Thread Anders Karlsson
This is a pretty weird thing. If you have no rows returned, and want to taka an action on that, then the application should check for the case of no rows returned, not for a specific value. But if you insist and use MySQL 4.1 (as subqueries are assumed): SELECT IFNULL((SELECT nameColumn FROM the

Re: Enforce value on select

2004-10-11 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, John Mistler <[EMAIL PROTECTED]> writes: > Good idea. liang le's answer almost got it, but I couldn't make it work > with string values quite right. Here is my situation: > I am issuing a series of queries all-in-one like "SELECT nameColumn, > otherColumn FROM th

Re: Enforce value on select

2004-10-10 Thread John Mistler
Good idea. liang le's answer almost got it, but I couldn't make it work with string values quite right. Here is my situation: I am issuing a series of queries all-in-one like "SELECT nameColumn, otherColumn FROM theDatabase WHERE rowID = 1;SELECT nameColumn, otherColumn FROM theDatabase WHERE ro

Re: Enforce value on select

2004-10-10 Thread Michael Stassen
Then how will you know the difference between a row with nameColumn = 0 (or '') and one that doesn't exist? What you are asking for seems very strange. You want the db to pretend there's a value for nonexistent rows. If rowID 5 should have the value 0, then I wonder why there isn't a row with

Re: Enforce value on select

2004-10-10 Thread John Mistler
Thanks for the reply. There is a slight difference in what I need from the "IFNULL" function. It will only return the specified value if the column is null on a row that actually exists. I am needing a function that will return the specified value if the row does NOT exist. Any other ideas? SE

Re: Enforce value on select

2004-10-10 Thread Martin Gainty
John You will have to soemthing similar to Oracle Decode Martin- - Original Message - From: "John Mistler" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, October 10, 2004 9:23 PM Subject: Enforce value on select > Is there a way to force SOME value to

Enforce value on select

2004-10-10 Thread John Mistler
Is there a way to force SOME value to be returned from a SELECT query when the result is empty set? For instance: SELECT nameColumn from theDatabase WHERE rowID = 5; (when no row has ID "5") result --> empty set I would like for it to return some value, such as '' or 0 . . . Thanks, John -