Categories
status

Add comments on a mysql table CREATE …

Add comments on a mysql table

CREATE TABLE testing (
name VARCHAR(5)
) COMMENT=’this is testing’;
How to view the comment:

Or add comments after making a table by
ALTER TABLE tablename COMMENT = ‘new updated comment’;

To see the comments

SHOW CREATE TABLE testing;

Source

Categories
status

How to select the first/least/max row pe …

How to select the first/least/max row per group in SQL

A nice explanation about the subject. Easy to understand.
http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

Categories
status

Find duplicates in MySQL SELECT col1, …

Find duplicates in MySQL

SELECT col1, col2, count(col3)
FROM t1
GROUP BY col1, col2
HAVING count(col3) > 1

Adapted from
http://support.microsoft.com/default.aspx?scid=kb;en-us;139444