Ad Code

Multiple IF statements on MYSQL

SELECT item_code, 
CASE category_code 
WHEN 'HERR1' THEN 1
WHEN 'COLN5' THEN 2
ELSE 'NO'
END as category_code, item_name, item_quantity 
FROM qa_items

Method - 2:
CASE pay_mode
WHEN 1 THEN "Cash"
WHEN 2 THEN "Website / Online"
WHEN 3 THEN "Deposit / Funds Transfer"
WHEN 4 THEN "Cheque"
WHEN 5 THEN "Payment Gateway"
WHEN 6 THEN "Credit / Debit Card"
ELSE "NA"
END as PaymentMode,

CASE status
WHEN 1 THEN "Approved"
WHEN 2 THEN "Rejected"
ELSE "Pending"
END as Status,

Post a Comment

0 Comments