UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 11th June 2008, 12:57 PM   #1 (permalink)
wmuckell
Senior Member
 
wmuckell's Avatar
 
Join Date: May 2004
Location: Marden, Kent
Posts: 179
Mysql Select On Varchar Treat As Number

I have a database table with PRICE as a varchar. However I want to do a search for those value in the table that are < 1000 for example. And this will disclude all the other STRING values, lik POA etc.

Any ideas?
wmuckell is offline   Reply With Quote
Old 11th June 2008, 02:53 PM   #2 (permalink)
APC-Andy
Registered User
 
Join Date: Jun 2008
Posts: 9
Look into the MySQL functions Cast and Convert

MySQL :: MySQL 5.0 Reference Manual :: 9.1.7.2 CONVERT() and CAST()

Depending on how often you will be querying it may be more efficient to store the numeric values in a separate column instead of using the above method.

HTH

Andrew
APC-Andy is offline   Reply With Quote
Old 11th June 2008, 03:37 PM   #3 (permalink)
wmuckell
Senior Member
 
wmuckell's Avatar
 
Join Date: May 2004
Location: Marden, Kent
Posts: 179
Quote:
Originally Posted by APC-Andy View Post
Look into the MySQL functions Cast and Convert

MySQL :: MySQL 5.0 Reference Manual :: 9.1.7.2 CONVERT() and CAST()

Depending on how often you will be querying it may be more efficient to store the numeric values in a separate column instead of using the above method.

HTH

Andrew
Tried both

WHERE CONVERT(ad_price, DECIMAL) < 1000

and

WHERE CAST(ad_price as DECIMAL) < 1000

and neither worked??
wmuckell is offline   Reply With Quote
Reply


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

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 Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 07:47 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309