MySQL Ordering Data - help

DOSMANDOSMAN Grand Rapids, MI
edited September 2004 in Internet & Media
Ok, I have a database which looks like the following

CREATE TABLE stuff (
id int(10) NOT NULL auto_increment,
title varchar(255) default NULL,
info varchar(50) default NULL,
PRIMARY KEY (id,issue)
) TYPE=MyISAM;

A lot of the entries in the database have the exact same title. The different things are distinguished by the info field.

When I do a "SELECT * FROM stuff ORDER BY title", it displays everything, but not in the order I want. It sorts every title alphabetically, but when it gets to displaying fields with the same title, it orders those by id.

How can I get the database to order entries with the same title by info instead of id? Essentially, I want my database to display in alphabetical order by title, and then by info as a secondary check, if the titles are the same.

Comments

  • ShortyShorty Manchester, UK Icrontian
    edited September 2004
    "SELECT * FROM stuff ORDER BY title ASC, info ASC"

    ASC = ascending.

    Change to DESC if you so wish :)
  • DOSMANDOSMAN Grand Rapids, MI
    edited September 2004
    Sweet!

    You rock. I really need to work on my SQL syntax.
Sign In or Register to comment.