If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > str() function equivalent for mysql?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-04, 13:15
xayavon xayavon is offline
Registered User
 
Join Date: Dec 2003
Posts: 23
str() function equivalent for mysql?

In sql server the str() function converts numeric data into character data. Is there any such function in mysql?

Thanks,

xayavon
Reply With Quote
  #2 (permalink)  
Old 02-04-04, 14:01
vanekl vanekl is offline
Registered User
 
Join Date: Nov 2003
Posts: 91
The closest thing to STR() that MySQL has is FORMAT().

FORMAT(X,D)
Formats the number X to a format like '#,###,###.##', rounded to D decimals, and returns the result as a string. If D is 0, the result will have no decimal point or fractional part:
mysql> SELECT FORMAT(12332.123456, 4);
-> '12,332.1235'
mysql> SELECT FORMAT(12332.1,4);
-> '12,332.1000'
mysql> SELECT FORMAT(12332.2,0);
-> '12,332'


You may also want to look into CAST or CONVERT.
CAST() and CONVERT() are available as of MySQL 4.0.2.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On