I want to pick students based on user input to a select query.


if input = -1 which means all students .. then I want to select all students

if input = studentId then I want to select that specific student only.

my problem is , How do I feed these conditions into where clause of the select query ?

As far as I know I can not use IF ELSE in where clause. What is the way to select students based on conditions ?

What should be the structure of the query ?