Have a problem with this query, when xBatch is empty or at least seems
to be empty.
Using DWMX, MySQL, and PHP
SELECT donations.id, donations.batch , donations.oikos _id,
donations.giftD ate, donations.genFu nd, donations.misFu nd,
donations.benFu nd, donations.notes , oikos.id, oikos.famLabel
FROM donations, oikos
WHERE IF(xBatch = '', donations.batch > 0, donations.batch = xBatch) AND
donations.oikos _id = oikos.id
ORDER BY donations.batch , donations.giftD ate, donations.oikos _id
xBatch = $HTTP_GET_VARS['searchBatch'] - Comes from a form field named
"searchBatc h."
When "searchBatc h" is empty and thus makes xBatch empty, I get the
following SQL error.
You have an error in your SQL syntax. Check the manual that corresponds
to your MySQL server version for the right syntax to use near '= '',
donations.batch > 0, donations.batch = ) AND donations.oi
Why isn't the conditional statement fixing the problem? Any suggestions?
-Dave
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw