我有任何表达式现在我需要在我的sql数据库记录上运行请帮我用sql这里是代码
if (( (gpa == edu.gpa || gpa <= 0) && (edu.gpa.Equals(gpa) || string.IsNullOrEmpty(gpa))
我尝试过类似的转换为SQL查询,如
SELECT *
FROM education
WHERE (gpa >= somevalue OR gpa =0 )
AND (degree = 'somevalue' OR degree is NULL)
如果用户在过滤器中输入空值,则此查询不会返回正确的结果。
答案 0 :(得分:0)
试试这个:
SELECT *
FROM education
WHERE (gpa IS NULL OR gpa >= somevalue OR gpa =0 )
AND (degree is NULL OR degree = 'somevalue' OR TRIM(degree) = '')
试试this SQL Fiddle并告诉我们。
答案 1 :(得分:0)
试试这个
SELECT *
FROM education
WHERE (degree = 'somevalue' OR degree is NULL)
HAVING gpa >= somevalue OR gpa =0