-2

How can write the below

SELECT
    a1.state, b2.name,........* 
FROM
    Table_Name
WHERE
    condition1
    AND condition2
    AND condition3
    AND condition4
    AND IF b2.name = 'mohan' THEN condition 5
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 3
    Does this answer your question? [How do I perform an IF...THEN in an SQL SELECT?](https://stackoverflow.com/questions/63447/how-do-i-perform-an-if-then-in-an-sql-select) – Charlieface Jan 06 '21 at 23:07

1 Answers1

0

You don't need if. Just use boolean logic:

where condition1 AND
      condition2 AND
      condition3 AND
      condition4 AND
      (b2.name <> 'mohan' OR condition 5)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786