Solved

phpmyadmin no negative numbers

Posted on 2010-08-18
4
476 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 108

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:
shinuq 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now