Solved

if in mysql

Posted on 2012-03-09
5
277 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
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:theGhost_k8
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:
theGhost_k8 earned 500 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
A short film showing how OnPage and Connectwise integration works.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

919 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

21 Experts available now in Live!

Get 1:1 Help Now