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

What field types in MySQL can store decimals and integers?

WBOY
Release: 2023-03-03 09:46:02
Original
2462 people have browsed it

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template