Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Database
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 05-31-2007, 8:46 PM   #1
Jeff Grossman
 
Jeff Grossman's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Order By Problem

I am having a problem with an order by command in my select statement.
I have a column heading which a user can click on and it will sort that
column. Here is my code:

} elseif ($sort == "price") {
if(($stores != "") or ($type9 != "") or ($make9 != "")) {
$result .= " WHERE id is not null";
if($stores != "") {
$result .= " AND store = '{$stores}'";
}
if($type9 != "") {
$result .= " AND category = '{$type9}'";
}
if($make9 != "") {
$result .= " AND make = '{$make9}'";
}
}
$result .= " order by price";


The price column is defined as a VARCHAR(25) column. When I click on
the price column and have it sort, it sorts as follows:

1050.00
110.00
119.99
125.00
1250.00
129.99
1299.99
149.99
174.99
190.00

How can I make it sort in numerical order?

Thanks for any help you can offer me.

Jeff
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 05-31-2007, 8:46 PM   #2
Jeff Grossman
 
Jeff Grossman's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Order By Problem

In alt.comp.databases.mysql Jeff Grossman <jeff@stikman.com> wrote:
> I am having a problem with an order by command in my select statement.
> I have a column heading which a user can click on and it will sort that
> column. Here is my code:
>

[CODE SNIPPED]
>
> The price column is defined as a VARCHAR(25) column. When I click on
> the price column and have it sort, it sorts as follows:
>
> 1050.00
> 110.00
> 119.99
> 125.00
> 1250.00
> 129.99
> 1299.99
> 149.99
> 174.99
> 190.00
>


Sorry to waste anybody's time. I figured out my problem. I was using a
character field when I should have been using an integer field. I have
done an alter table and changed the field to be an integer and now it is
sorting the way I want.

Jeff
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 05-31-2007, 8:46 PM   #3
Andy Jeffries
 
Andy Jeffries's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Order By Problem

On Mon, 07 Nov 2005 20:21:15 -0800, Jeff Grossman wrote:
>> 119.99
>> 129.99
>> 1299.99
>> 149.99
>> 174.99
>>

> Sorry to waste anybody's time. I figured out my problem. I was using a
> character field when I should have been using an integer field. I have
> done an alter table and changed the field to be an integer and now it is
> sorting the way I want.


If you want to store 129.99 you want a float column not an integer column.

Cheers,


Andy

--
Andy Jeffries | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 05-31-2007, 8:46 PM   #4
Jeff Grossman
 
Jeff Grossman's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Order By Problem

In alt.comp.databases.mysql Andy Jeffries <news@andyjeffries.co.uk> wrote:
> On Mon, 07 Nov 2005 20:21:15 -0800, Jeff Grossman wrote:
>>> 119.99
>>> 129.99
>>> 1299.99
>>> 149.99
>>> 174.99
>>>

>> Sorry to waste anybody's time. I figured out my problem. I was using a
>> character field when I should have been using an integer field. I have
>> done an alter table and changed the field to be an integer and now it is
>> sorting the way I want.

>
> If you want to store 129.99 you want a float column not an integer column.


Wow, it looks like I screwed that one up. I am going to go change the
column to a float. I am now noticing that I lost all of my cent figures
when I changed it to an integer.

Jeff
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 05-31-2007, 8:47 PM   #5
Marc Bissonnette
 
Marc Bissonnette's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Order By Problem

Jeff Grossman <jeff.nospam@stikman.com> wrote in
news:s25743xg2t.ln2@stikman.com:

> In alt.comp.databases.mysql Andy Jeffries <news@andyjeffries.co.uk>
> wrote:
>> On Mon, 07 Nov 2005 20:21:15 -0800, Jeff Grossman wrote:
>>>> 119.99
>>>> 129.99
>>>> 1299.99
>>>> 149.99
>>>> 174.99
>>>>
>>> Sorry to waste anybody's time. I figured out my problem. I was
>>> using a character field when I should have been using an integer
>>> field. I have done an alter table and changed the field to be an
>>> integer and now it is sorting the way I want.

>>
>> If you want to store 129.99 you want a float column not an integer
>> column.

>
> Wow, it looks like I screwed that one up. I am going to go change the
> column to a float. I am now noticing that I lost all of my cent
> figures when I changed it to an integer.


But of course, no time was lost, 'cuz you can restore from your backups,
right ?

<evil grin>



--
Marc Bissonnette
CGI / Database / Web Management Tools: http://www.internalysis.com
Looking for a new ISP? http://www.canadianisp.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 05-31-2007, 8:47 PM   #6
Jeff Grossman
 
Jeff Grossman's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Order By Problem

In alt.comp.databases.mysql Marc Bissonnette <dragnet@internalysis.com> wrote:
> But of course, no time was lost, 'cuz you can restore from your backups,
> right ?
>
> <evil grin>
>

Backups? Who needs backups?
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Order food online hockney Community Chat 8 10-29-2007 10:19 AM
Fuh Yuan apologizes for wrong Walmart cheap HD-DVD order report Skwisgaar Skwigelf Computer Consoles 0 05-30-2007 8:44 PM
*** 15 mail order Plans You Can Sell ! Cash in now *** Felix Building An Internet Business 0 05-29-2007 1:39 AM
Looking for an app that will fill CDs or DVDs in directory order (see inside) Gazwad Windows 0 05-28-2007 11:29 PM
replicatable Folder Search problem : is source of problem Windows Desktop Search ? Bill Woodruff MSN questions 0 05-28-2007 1:45 AM


Featured Websites




All times are GMT +1. The time now is 11:50 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98