Solved

phpmyadmin no negative numbers

Posted on 2010-08-18
4
490 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

739 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