Using “group by” and “having” with MySQL

With SQL queries you can combine the “GROUP BY” syntax with “HAVING” to return rows that match a certain count etc. This post looks at how to return rows based on a count using having specifically tested on MySQL but it should work for other database servers as well. An example table might be an …

Read more

How to enable remote access to a MySQL database server

MySQL is often configured to be accessible from the local host only. Recently I moved all my websites from a CentOS box to a Debian one and needed to be able to connect to the MySQL server on the new box from the old one, but was not able to. This post looks at how to enable MySQL to be accessible from remote servers.

Randomly ordering a MySQL result set

There are times when you might need to randomly order a MySQL resultset, for example when choosing some winners at random for a prize draw. This post looks at how you would do this and also offers some advice if you need to "randomly" order data across multiple pages.

String concatenation with MySQL – Part 1

MySQL has a number of string handling functions including functions to concatenate text or database columns into a single column in the resultset. I’m always forgettingthat the function is CONCAT and not CONCATENATE so maybe by writing about it I will actually remember…

Copy a table in MySQL with CREATE TABLE LIKE

On Wednesday I wrote a post about how to copy a table in MySQL using the SHOW CREATE TABLE sql query. Since then Paul Williams in the UK emailed me to let me know that there’s a much easier way to do this using CREATE TABLE LIKE, a function which was depths of my brain somewhere but I’d since forgotten. This post revises and republishes my previous post using this simpler process.