Andrew Stacey


About
Andrew Stacey
Information about my research, teaching, and other interests.

By: Andrew Stacey
Contact details


Andrew Stacey


blosxom icon


Mon, 9th Nov 2009 (HowDidIDoThat :: nLab)

MySql Notes

Some useful MySQL queries:

  1. Find all revisions from a particular IP:

    SELECT page_id,updated_at FROM revisions WHERE ip = "X.X.X.X";
    
  2. Find all revisions for yesterday:

    SELECT name FROM pages WHERE id IN (SELECT page_id FROM revisions WHERE DATE(updated_at) = DATE_SUB(CURDATE(),INTERVAL 1 DAY));
    
  3. Check column settings:

    SHOW FULL COLUMNS FROM table;
    
  4. Reset columns to case-sensitive (with appropriate settings):

    ALTER TABLE `table` MODIFY `column` type CHARACTER SET charset COLLATE collation NOT NULL? DEFAULT?;
    

    The point here is that all this information has to be given, it doesn't work just trying to change the collation.

  5. Find unique entries from a column:

    SELECT DISTINT column FROM table;
    

[Full link]
Last modified on:
Tue, 9th Mar 2010