I have not used an 'if' clause in select before but I think I may have a scenario which calls for it.

I have a table with the following sample data:

idx  status1  status2
1    "Neg"    "Neg"
2    "Pos"    "Neg"
3    "Neg"    NULL
4    "Ind"    "Neg"

I need to write a select clause based on the following conditions:

If all rows of status1 == "Neg"
count all "Neg" rows in status1
else
check if all rows of status2 == "Neg"
  count all "Neg" rows in status2 and status1
endif
endif

So, in this case, it should return a count of 5 "Neg". If there is even one "Pos" or "Ind" in one of the rows of status2, it would have returned nothing.

Thanks for any help in advance.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to