Solved

if in mysql

Posted on 2012-03-09
5
276 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
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:sniper038
Comment Utility
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:theGhost_k8
Comment Utility
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
Comment Utility
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:
theGhost_k8 earned 500 total points
Comment Utility
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
Comment Utility
Hi
and really i did it the first time and it did not work for me..
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now