I am writing one query, that needs to satisfy the following conditions.
select field1, field2, field3 from `tabFirstTable`as ft join `tabSecondTable` as st where --Upto above its fine but how to turn below logic into query-- IF ft.approval_status in == 'Approved By Manager' and ft.status in ("Created", "Error") and //some more conditions ELSE ft.approval_status in == 'Approved By HOD' and ft.status in ("Initiated") and //some more conditions
Because of the above issue currently writing two separate queries, which is not a good idea. Please help.
Advertisement
Answer
Unless I am missing something or over simplifying
WHERE (ft.status IN ('Created', 'Error') AND ft.approval_status = 'Approved By Manager' AND //other stuff ) OR (ft.status = 'Initiated' AND ft.approval_status = 'Approved By HOD' AND //some more conditions )