How to write a delete query after checking?
Description:-
perform a delete SQL query after checking whether the record is present or not.
anyone can use this method to perform other query operations.
Example:-
| user_id | user_name | user_email |
1 | Arun | [email protected] |
2 | Sujan | [email protected] |
3 | Rohit | [email protected] |
SQL:-
IF EXISTS (
SELECT *
FROM user
WHERE user_email = '[email protected]'
)
BEGIN
DELETE
FROM user
WHERE user_email = '[email protected]'
END
Result:-
| user_id | user_name | user_email |
1 | Arun | [email protected] |
2 | Sujan | [email protected] |
