ansi-sql

How to rewrite IS DISTINCT FROM and IS NOT DISTINCT FROM?

梦想的初衷 提交于 2019-11-26 08:56:11
问题 How do you rewrite expressions containing the standard IS DISTINCT FROM and IS NOT DISTINCT FROM operators in SQL implementations such as Microsoft SQL Server 2008R2 that do not support them? 回答1: The IS DISTINCT FROM predicate was introduced as feature T151 of SQL:1999, and its readable negation, IS NOT DISTINCT FROM , was added as feature T152 of SQL:2003. The purpose of these predicates is to guarantee that the result of comparing two values is either True or False , never Unknown . These

Is there an ANSI SQL alternative to the MYSQL LIMIT keyword?

旧城冷巷雨未停 提交于 2019-11-26 04:23:56
问题 Is there an ANSI SQL alternative to the MYSQL LIMIT keyword? The LIMIT keyword limits the number of rows returned by a SELECT e.g: SELECT * FROM People WHERE Age > 18 LIMIT 2; returns 2 rows. SELECT * FROM People WHERE Age > 18 LIMIT 10, 2; returns 2 rows after the first 10. 回答1: this shows the different ways: -- DB2 select * from table fetch first 10 rows only -- Informix select first 10 * from table -- Microsoft SQL Server and Access select top 10 * from table -- MySQL and PostgreSQL select

Why does MySQL allow “group by” queries WITHOUT aggregate functions?

和自甴很熟 提交于 2019-11-26 02:37:55
问题 Surprise -- this is a perfectly valid query in MySQL: select X, Y from someTable group by X If you tried this query in Oracle or SQL Server, you’d get the natural error message: Column \'Y\' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. So how does MySQL determine which Y to show for each X? It just picks one. From what I can tell, it just picks the first Y it finds. The rationale being, if Y is neither an aggregate function

Why isn't SQL ANSI-92 standard better adopted over ANSI-89?

二次信任 提交于 2019-11-25 23:25:30
问题 At every company I have worked at, I have found that people are still writing their SQL queries in the ANSI-89 standard: select a.id, b.id, b.address_1 from person a, address b where a.id = b.id rather than the ANSI-92 standard: select a.id, b.id, b.address_1 from person a inner join address b on a.id = b.id For an extremely simple query like this, there\'s not a big difference in readability, but for large queries I find that having my join criteria grouped in with listing out the table