Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

if $new_input is empty do not update

Posted on 2013-01-18
4
Medium Priority
?
235 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 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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

610 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