MySQL Ordering Data - help
DOSMAN
Grand Rapids, MI
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.
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.
0
Comments
ASC = ascending.
Change to DESC if you so wish
You rock. I really need to work on my SQL syntax.