if $new_input is empty do not update

using php to update $new_input to varchar column

if $new_input is empty do not update


this has to be writen in mysql not php
LVL 1
rgb192Asked:
Who is Participating?
 
EndreCzCommented:
You need something like this:

UPDATE table SET column='$new_input' WHERE LENGTH('$new_input')>0
0
 
Lukasz ChmielewskiCommented:
This would require a conditional statement and this function,
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_length

Wouldn't that be easier if you'd check the variable from php ?
0
 
rgb192Author Commented:
I understand length
SELECT LENGTH('text');
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_length


but do not understand how to do conditional statement


the if in php would be too complex
I would rather do in mysql so I can test in query editor
0
 
rgb192Author Commented:
the former introduced length and the latter applied length and a conditional statement to a sample query. Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.