[Solved]SQL statement question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

[Solved]SQL statement question

Post by John Cartwright »

This is my current statement

Code: Select all

<?php

$sql = "SELECT * FROM customercare WHERE (catagory = 'Shipping') ORDER BY `subheader` ASC";

?>
How do I make it order by subheader AND then by ID ( or anything else )
Mactek
Forum Commoner
Posts: 28
Joined: Tue Oct 28, 2003 1:19 pm
Location: Boston

Post by Mactek »

try this:

$sql = "SELECT * FROM customercare WHERE (catagory = 'Shipping') ORDER BY `subheader`, `id` ASC";
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

thank ya! :P
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Okay that worked perfect... but there is 1 more problem

I need them to sort by subheader... so my db looks like this

text --- subheader
blah ---- blah1
blah ---- blah1
blah ---- blah1
blah ---- blah2
blah ---- blah3

But now I need to order the actual subheaders on my page :S :S... what is a good way to go about this. How can I choose the order of the subheaders without having to numberate them or something?

Help, ty
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

up
Post Reply