Home  >  Article  >  Backend Development  >  What field types in MySQL can store decimals and integers?

What field types in MySQL can store decimals and integers?

WBOY
WBOYOriginal
2016-12-05 13:44:182430browse

There is a field that can store integers and decimals, such as 43 and 43,000 yuan. Both can be saved. How should it be set?

Reply content:

There is a field that can store integers and decimals, such as 43 and 43,000 yuan. Both can be saved. How should it be set?

Different types of storage results:

decimal: 43.00 4.30

varchar: 43 4.3

It doesn’t matter what you feel, display it according to your needs or consider the storage format based on performance

Are you talking about 43 or 4.3 or 43 or 43,000 yuan? If it is the former, then it is best to use decimal. If the number of digits is uncertain and precision is not required, double can also be used. Otherwise it can only be strings

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn