Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 07-03-2009, 10:08 PM   #1 (permalink)
v7n Mentor
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 662
iTrader: 0 / 0%
Latest Blog:
None

Leon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of light
[MySQL] Order By Issue

Sup Folks.

I have a problem with ORDER BY and numbers + characters. I have strings in my database that look like this: "$75.00 or XYZ for $300.00" and most of the strings look more like "$125", "$235" etc. well when you order by the field by say DESC it does this:

"$75.00 or XYZ for $300.00"
"$235"
"$125"

When what I really want is:

"$235"
"$125"
"$75.0 or XYZ for $300.00"

Someone suggested that I do "ORDER BY string+0" and that gives a great result if you just want "ASC" but I want to have the ability to do both ASC and DESC. I can't make the type a INT either because they want to be able to put normal characters in the string.
Leon is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-05-2009, 03:12 PM   #2 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
This is because the column is a String, not a double.

You need to set the column as a DOUBLE and get the double type from the database, then stick a '$' (dollar sign) in front of it when you output it to the user.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is online now  
Add Post to del.icio.us
Reply With Quote
Old 07-13-2009, 03:35 PM   #3 (permalink)
v7n Mentor
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 662
iTrader: 0 / 0%
Latest Blog:
None

Leon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of light
I ended up restructuring the DB to do it correctly.
Leon is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


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

BB 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
WOMD - Issue or Non-issue John Scott Controversial Social Issues 1 08-02-2007 09:30 AM
mySQL Issue Sketch Coding Forum 8 01-17-2007 12:09 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 06:14 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.