List of Useful MySQL Commands

Here is a list of some important queries that I have had to use with MySQL. Some of these are very helpful, others are plain invaluable.

View all the queries/threads/process that are running:

SHOW PROCESSLIST;

Link to MySQL reference manual

Kill a certain query that is long running:

Bring up the the processlist by using the SHOW PROCESSLIST; command, then
KILL <thread_id>;

Link to MySQL reference manual

Count the number of unique records given a column name:
SELECT COUNT(DISTINCT column_name) FROM table_name;

Introduction to stored procedures

When you need to really got a big job done, and just a simple is limiting you...

Gilfster: MySQL 5.0 Stored Procedures

Link to MySQL reference manual

Database Journal - Part 1 and Part 2

Implementing Cursors - Sequential step through of a given recordset:

Unfortunately, there is no one liner that will do it. But below are some links to get started.

Link to MySQL reference manual

Roland Bourman's blog: Nested MySQL Cursor Loops

Difference between a Where clause and a Having clause - when using Group By

This site, has a great explaination with example queries and results.

Database Journal - Having and Group By