I am using a SQL Server database.
This query:
SELECT *
FROM table1
WHERE table1.name = 'something'
AND CASE
WHEN table1.date IS NULL THEN 1 = 1
ELSE table1.date >= '2013-09-24'
END;
gives me en error:
[Error Code: 102, SQL State: S0001] Incorrect syntax near '='.
Any help is appreciated,
Thanks in advance
mismas
I think this is what you want.
select
*
from
table1
where
table1.name = 'something' and (
table1.date is null or
table1.date >= '2013-09-24'
);
SQL Server doesn't really have a boolean type that you can use as a result.
Try this code:
select *
from table1
where table1.name='something'
and (table1.date is null Or table1.date >= '2013-09-24');
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