I've a table called user_transaction
in my database.The actual table has too many fields but the field I'm having issue in is as follows:
Column : transaction_status
Type : enum('success', 'inprocess', 'fail', 'cancelled')
Now the scenario is there are four checkboxes on the HTML form for the four transaction statuses. When user checks one or more checkboxes then he/she should get the desired transactions with the checkbox(or checkboxes) he/she has checked. For fetching the data from table I wrote following query if checkbox inprocess and success are selected.
SELECT transaction_user_id, transaction_no, transaction_total_amount, transaction_date,
transaction_status
FROM OCN.user_transaction
WHERE transaction_date >= '949516200' AND transaction_date <= '1391452199'
AND transaction_status = "inprocess" OR transaction_status = "success"
ORDER BY transaction_date LIMIT 0, 20
The above query is expected to return me the transactions whose transaction status is either success or inprocess but it returns nothing. Also the same case if I select other two or all the checkboxes. Can anyone help me in this regard please?
you need paranthesis around the multiple conditionals.
SELECT transaction_user_id, transaction_no, transaction_total_amount, transaction_date, transaction_status FROM OCN.user_transaction WHERE transaction_date >= '949516200' AND transaction_date <= '1391452199' AND (transaction_status = "inprocess" OR transaction_status = "success") ORDER BY transaction_date LIMIT 0, 20