Welcome to WebmasterWorld Guest from 54.160.177.33

Forum Moderators: open

Message Too Old, No Replies

Converting a number to a positive number in MySQL

     
11:13 pm on May 19, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 12, 2004
posts: 1355
votes: 0


This seems like it would be simple, but I can't figure out how to do it.

I have a value which may or may not be positive, but I need it to be positive every time. Is there a function for this?
3:21 pm on May 20, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 9, 2003
posts:3416
votes: 0


You can get the absolute value using ABS():
http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_abs [dev.mysql.com]
3:33 pm on May 20, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 12, 2004
posts: 1355
votes: 0


Oh, that's exactly what I was looking for. I should have known that.

Thanks!