Home > Article > Backend Development > What field types in MySQL can store decimals and integers?
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: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