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.giftDate, donations.genFund, donations.misFund,
donations.benFund, 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.giftDate, donations.oikos_id
xBatch = $HTTP_GET_VARS['searchBatch'] - Comes from a form field named
"searchBatch."
When "searchBatch" 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