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 rowID=5 and value=0. If it's just a matter of treating non-existent rows as having 0 value in your app, why don't you simply code that into your app? In other words, I find it hard to provide a solution, because I don't understand what you want. Perhaps if you explained it, someone could suggest how best to accomplish it.
Michael
John Mistler wrote:
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?
SELECT nameColumn from theDatabase WHERE rowID = 5;
(when no row has ID "5")
result --> empty set (I want a value like '0' or something)
Thanks again!
-John
on 10/10/04 8:12 PM, liang lei at [EMAIL PROTECTED] wrote:
--- John Mistler <[EMAIL PROTECTED]>
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
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
select ifnull(column,'0') from table
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]