I am passing where clause parameter values from a program however when I am sending at least one one value I get the result however if I am sending all parameters as null no output is coming, i want a query such that if all parameters are sent as null will display all the records in the database
following is the query which retrieves values if one condition is satisfied
SELECT *
FROM STUDENT
LEFT JOIN COURSE
ON STUDENT.COURSE_ID = COURSE.COURSE_ID
WHERE STUDENT.STD_ID = null
OR STUDENT.STD_NAME = null
OR STUDENT.STD_START_DATE = null
OR STUDENT.STD_END_DATE = null
OR STUDENT.STD_GENDER = null
OR STUDENT.COURSE_ID = null;
Try below,
SELECT *
FROM STUDENT
LEFT JOIN COURSE
ON STUDENT.COURSE_ID = COURSE.COURSE_ID
WHERE STUDENT.STD_ID IS NULL
OR STUDENT.STD_NAME IS NULL
OR STUDENT.STD_START_DATE IS NULL
OR STUDENT.STD_END_DATE IS NULL
OR STUDENT.STD_GENDER IS NULL
OR STUDENT.COURSE_ID IS NULL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With