[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

if $new_input is empty do not update

Posted on 2013-01-18
4
Medium Priority
?
236 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
  • 2
4 Comments
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 800 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 1200 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

873 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