|
-
Oct 22nd, 2002, 03:41 AM
#1
Thread Starter
Hyperactive Member
An SQL String Question
This is more of a general SQL question rather than specific PHP but I couldn't find a better section to post it on!
Is there a way of doing an SQL statement that says "Replace any field in this row with a 0 if that field is a null"?
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Oct 22nd, 2002, 12:30 PM
#2
No, since there could be fields (like VARCHAR or BLOB) that don't accept 0 as value. In one query you could set every field to 0 (or something similar) if the field you check for in the row is null.
But you could use more than one query like
UPDATE tablename fieldname='0' WHERE fieldname=NULL
UPDATE tablename otherfield='0' WHERE otherfield=NULL
But don't rely on what I've said, I've never got deep into obscure SQL commands.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 22nd, 2002, 12:37 PM
#3
Stuck in the 80s
Maybe a better answer could be generated if you told us why you need to do something like this?
Surely setting a default would make their no need for a code approach, if that's what your problem is.
Maybe you could explain?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|