I have this query which might return multiple results. Is it possible to sort it and display in the following order: pending, failed, application, submitted, canceled ?
i.e sort by pa.status as above.
SELECT
cl.id,cl.lead_id,cl.client_name,po.id,po.carrier,
pa.downpayment_time,pa.status,pa.policy_id
FROM
pdp_client_info AS cl,
pdp_policy_info AS po,
pdp_payment AS pa
WHERE
cl.id = po.id AND po.id=pa.policy_id
AND pa.downpayment_date = '$current_date'
AND (pa.status='pending'
OR pa.status='failed'
OR pa.status='application'
OR pa.status='submitted'
OR pa.status='canceled')
Use the
FIND_IN_SETfunction:http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_find-in-set
Code will look like this:
Here is how I would rewrite your SQL query: