Solved

phpmyadmin no negative numbers

Posted on 2010-08-18
4
487 Views
Last Modified: 2013-12-13
Is there a way in phpmyadmin to set a field in mysql to be 0 if the result is less than 0? I'm trying to determine how long to pay off my credit card. If the time remaining is a negative number i'd like that field to be 0. Any suggestions anyone?
0
Comment
Question by:gatormrr3
4 Comments
 
LVL 31

Assisted Solution

by:Frosty555
Frosty555 earned 63 total points
ID: 33469890
You can create a view or a query with a custom column, set to something like

IF(myfield>0,myfield,0) AS myfieldnonegative

then when you select from that view, or execute that query, the resulting recordset will have a column "myfieldnonegative" which will be the result you're looking for.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 33469991
"...  if the result is less than 0?"

If what result is less than zero?
0
 
LVL 17

Accepted Solution

by:
Shinesh Premrajan earned 62 total points
ID: 33472156
Define that field as unsigned integer.

Hope this helps
0
 

Author Closing Comment

by:gatormrr3
ID: 33476717
The code worked as well but the unsigned method was simpler and more error proof. Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question