Solved

if $new_input is empty do not update

Posted on 2013-01-18
4
233 Views
Last Modified: 2013-01-20
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
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 200 total points
ID: 38794136
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
 

Author Comment

by:rgb192
ID: 38794334
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
 
LVL 2

Accepted Solution

by:
EndreCz earned 300 total points
ID: 38796374
You need something like this:

UPDATE table SET column='$new_input' WHERE LENGTH('$new_input')>0
0
 

Author Closing Comment

by:rgb192
ID: 38799841
the former introduced length and the latter applied length and a conditional statement to a sample query. Thank you.
0

Featured Post

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question