Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

if in mysql

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
asaidi
Asked:
asaidi
  • 2
  • 2
1 Solution
 
sniper038Commented:
are you sure about your syntax?

IF(condition, value_if_condition_true, value_if_condition_false)

Open in new window

0
 
K VDatabase ConsultantCommented:
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
 
asaidiAuthor Commented:
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
 
K VDatabase ConsultantCommented:
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
 
asaidiAuthor Commented:
Hi
and really i did it the first time and it did not work for me..
thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now