SELECT NULLIF(1 > 0, 1);
SELECT NULLIF(1> 0,1);
In MySQL that returns NULL. In SQL Server it gives me a syntax error because of the <. eg.
在MySQL中返回NULL。在SQL Server中,由于<,它给我一个语法错误。例如。
SELECT 1 > 0;
SELECT 1> 0;
That, too, works fine in MySQL, but not in SQL Server. Any ideas as to what I can do to work around this?
这也适用于MySQL,但不适用于SQL Server。关于我可以做些什么来解决这个问题的任何想法?
Thanks!
1 个解决方案
#1
3
MySQL is more flexible than other databases in using calculations in queries. You can use CASE
statements in SQL Server to achieve the same results though:
在查询中使用MySQL时,MySQL比其他数据库更灵活。您可以在SQL Server中使用CASE语句来实现相同的结果:
SELECT CASE WHEN 1 > 0 THEN 1 ELSE 0 END
- SQL Fiddle Demo
SQL小提琴演示
#1
3
MySQL is more flexible than other databases in using calculations in queries. You can use CASE
statements in SQL Server to achieve the same results though:
在查询中使用MySQL时,MySQL比其他数据库更灵活。您可以在SQL Server中使用CASE语句来实现相同的结果:
SELECT CASE WHEN 1 > 0 THEN 1 ELSE 0 END
- SQL Fiddle Demo
SQL小提琴演示