Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

if in mysql

Posted on 2012-03-09
5
Medium Priority
?
284 Views
Last Modified: 2012-03-10
Hi mysql experts..
i have a table that have pulser1_name,pulser2_name,pulser3_name,pulser4_name
i want to test each one
i did this
$query1="select pulser1_name,pulser2_name,pulser3_name,pulser4_name from net_watch_units
         
         where serial_no=$netw AND IF(pulser1_name <>''), IF(pulser2_name<>''), IF(pulser3_name<>'')
,IF(pulser4_name<>'') ";

Open in new window

i want to display only the ones are not blank..
but my if is not working
any help please
0
Comment
Question by:asaidi
[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
  • 2
5 Comments
 
LVL 3

Expert Comment

by:sniper038
ID: 37704003
are you sure about your syntax?

IF(condition, value_if_condition_true, value_if_condition_false)

Open in new window

0
 
LVL 21

Expert Comment

by:K V
ID: 37704229
is it really required? >>> "IF"


$query1="select pulser1_name,pulser2_name,pulser3_name,pulser4_name from net_watch_units  where serial_no=$netw AND pulser1_name <>'' and pulser2_name<>'' and pulser3_name<>'' and pulser4_name<>'';"
0
 

Author Comment

by:asaidi
ID: 37704460
hi
yes otherwise i cannot make it work
if pulser1<>'' and the rest are blank the condition is not true,and normally pulser1 is true
0
 
LVL 21

Accepted Solution

by:
K V earned 2000 total points
ID: 37705232
Hey asaidi,
as (pulser1_name <>'' and pulser2_name<>'' and pulser3_name<>'' and pulser4_name<>'';") will return rows where all of these are having values, you may choose to use atleast one of these have value as:


$query1="select pulser1_name,pulser2_name,pulser3_name,pulser4_name from net_watch_units  where serial_no=$netw AND (pulser1_name <>'' OR pulser2_name<>'' OR pulser3_name<>'' OR pulser4_name<>'');"
0
 

Author Closing Comment

by:asaidi
ID: 37705663
Hi
and really i did it the first time and it did not work for me..
thanks
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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

722 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