I've the following query:
SELECT NAME, SURNAME FROM MY_TABLE WHERE NAME = ?;
Now I want that if '?' is NULL, all records have to be selected. How can I achieve this in SQL? Thanks
Try this:
SELECT * FROM MY_TABLE WHERE @parameter IS NULL OR NAME = @parameter;
2.1m questions
2.1m answers
60 comments
57.0k users