Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

phpmyadmin no negative numbers

Posted on 2010-08-18
4
Medium Priority
?
497 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 252 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 111

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 248 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
The viewer will learn how to dynamically set the form action using jQuery.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

916 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