Comments on: Less known SQL syntax and functions in MySQL https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql Blog by Shlomi Noach Tue, 04 May 2010 09:38:44 +0000 hourly 1 https://wordpress.org/?v=5.3.3 By: Discovery of the day: GROUP BY DESC | code.openark.org https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-13077 Tue, 04 May 2010 09:38:44 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-13077 […] are sorted according to the group statement. You can override this by adding ORDER BY NULL (see past post). I wasn’t aware you can actually control the sort […]

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-9573 Wed, 20 Jan 2010 06:56:31 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-9573 @Tim,

There’s some contradiction in your comment, I think. AFAIK, there is no LIMIT in ANSI SQL. Therefore, it is purely a MySQL extension. Thus, there is no “standard SQL way” for doing LIMIT.

Using one syntax over the other is a matter of preference and, in my case, and old habit. I agree using LIMIT with OFFSET is more verbose.

Regards

]]>
By: Tim https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-9548 Tue, 19 Jan 2010 19:24:05 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-9548 Your Oracle DBA was shocked that you’re using “LIMIT” for pagination because that syntax is a MySQL extension. The standard SQL way would be “LIMIT 10 OFFSET 60”.

MySQL also supports OFFSET, and it makes it clearer which number is which, so I’m not sure why you’d ever use “LIMIT a,b”.

]]>
By: Kannan https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-165 Fri, 19 Dec 2008 06:35:32 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-165 Good Post for MySQL.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-123 Wed, 17 Dec 2008 05:25:35 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-123 Hi Jason,

I’ve seen a very bad effect of REPLACE INTO in a production system. The overhead of DELETEing a row, then INSERTing a new one is huge, especially on InnoDB tables. Changing the code to INSERT INTO…ON DUPLICATE KEY reduced the load average on the db machine by factors.

]]>
By: Jason https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-120 Wed, 17 Dec 2008 02:14:38 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-120 I personally like the REPLACE INTO command… same syntax as INSERT INTO, except if it finds a duplicate key, it deletes it and replaces it….

Similar in spirit to the UPDATE… ON DUPLICATE KEY UPDATE, the difference being – REPLACE INTO will delete and then insert so you get incremented auto numbered IDs

]]>
By: A day in the life of… - Once a nomad, always a nomad https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-62 Tue, 02 Dec 2008 23:01:17 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-62 […] Bookmarked a link on Delicious. Less known SQL syntax and functions in MySQL | code.openark.org […]

]]>
By: rudy https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-47 Wed, 26 Nov 2008 01:04:03 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-47 there is another feature (some would not use this word) in mysql that is stunning in its implication — “hidden” columns in the GROUP BY

at first, i thought it was an egregious error that mysql would allow a query like this:

SELECT a, b, MAX(c) FROM t GROUP BY a

most databases toss an error about column b in the SELECT clause but not in the GROUP BY

read this article, which completely changed my mind on the issue — http://rpbouman.blogspot.com/2007/05/debunking-group-by-myths.html (also republished on mysql.com)

keep “functional dependency” in mind (from normalization theory) and see if you don’t agree that it can be exceptionally useful

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-46 Tue, 25 Nov 2008 14:12:05 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-46 Hi Nils,
CLUSTER in PostgreSQL seems to only work on an index, while
ALTER TABLE…ORDER BY will work on any columns.

]]>
By: Nils https://shlomi-noach.github.io/blog/mysql/less-known-sql-syntax-and-functions-in-mysql/comment-page-1#comment-45 Tue, 25 Nov 2008 12:55:57 +0000 https://shlomi-noach.github.io/blog/?p=126#comment-45 The ALTER TABLE … ORDER BY thing is similar to CLUSTER in postgres I think.

http://www.postgresql.org/docs/8.3/interactive/sql-cluster.html

]]>