I want to have a query that will let me select ALL from the table if the variable is null, and my only option here is PURE MYSQL here is my CODE
SELECT *
FROM tblPersonalData
if(VARIABLE!=null,WHERE Studno=VARIABLE},'all')
It's simple OR operation:
select
*
from tblPersonalData
where variable is null
or studNo = variable;
You can emulate this behavior with the logical or operator. Note, however, that null is not a value, and you should test it explicitly with the is or is not operators, not = or !=:
SELECT *
FROM tblPersonalData
WHERE variable IS NULL OR sutdno = variable
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