Jump to content

Archived

This topic is now archived and is closed to further replies.

Tandem

sql case statement

Recommended Posts

Hi, i am drawing the names of cars out of my database. There are 6 different types of car and i want to put them in a specific order. I'm pretty sure i need to use a case statement to do this but i can't remember exactly how to do it as i need it, and when i google it i can't find anything that is similar to what i'm looking for.

Can someone please demonstrate one for me?

Thanks.

Share this post


Link to post
Share on other sites
[code]
<?php

$sql = "SELECT carname, make, model, color FROM cars ORDER BY carname ASC";

$result = mysql_query($sql, $conn);

?>
[/code]

Share this post


Link to post
Share on other sites
Thats not what i mean at all.

I am drawing them by name only. The order is not alphabetical, it is a specific order set by me.

Share this post


Link to post
Share on other sites
[quote]The order is not alphabetical, it is a specific order set by me.[/quote]

Then you should create an [i]orderby[/i] field in your database and order by that.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.