Solved

phpmyadmin no negative numbers

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Init Waits 25 77
mimic google as my ip 11 53
[MYSQL]: Delete is very slow 4 52
.php tree directory? 5 54
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

932 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

11 Experts available now in Live!

Get 1:1 Help Now