vendredi 26 juin 2020

IF condition in where clause in SQL Server

I need to write the if condition in the where clause of SQL where I wanted to define that if one column is null then search in another column in a row. I have used union but it's making the query slow to execute, so help me write this statement in the proper way.

This is the code I have right now:

SELECT * 
FROM ACCOUNT 
WHERE (IF ACCOUNTID IS NULL THEN REF_ACC_ID = 12 ELSE ACCOUNTID = 12)

Aucun commentaire:

Enregistrer un commentaire