Solved

if in mysql

Posted on 2012-03-09
5
278 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL ERROR 1045 (28000) 2 81
updating table data with inner join 9 37
How do I call MySQL Stored Procedure from oracle using HS link ? 5 46
change database name 2 32
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…
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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