Jump to content

Too many "0" in my tables . . . how do I fix this?


CountryGirl

Recommended Posts

In several of the fields in my tables there are one too many 0's after the number. Like, say, there is a table that has a "YearBuilt" field in it. The year built is there, but after the year built, there are a bunch of extra zeros. Like this "1886.00000." Of course it comes through in the search results and obviously the company I'm working for doesn't like all the extra zeros.

 

In the original microsoft access DB there are not extra zeros in those fields. It's just there in the PHPMyAdmin tables. How do I fix that and get rid of the extra zeros?

 

Thanks!

Qadoshyah

Link to comment
Share on other sites

well if it's a year you probably want no zeros so (15,0)

Misread the OP. If its a year then why use double,? Why not just use INT if you're storing years.

 

I'm not sure. I wasn't the one who loaded the information into the PHPMyAdmin. It seems to be working though now with the double 15,0. I may see if INT works better though.

 

Thanks!

Qadoshyah

Link to comment
Share on other sites

Even better, MySQL has a YEAR(4) type.  The only caveat is that the year has to be in the range of 1901 to 2155.

 

Why should you care?  With the myisam engine, a double column requires 8 bytes, whereas a year only requires 1 byte!  Saving 7 bytes per row for both data and index if needed, is always extremely important to consider for a database of any significant size.

Link to comment
Share on other sites

Even better, MySQL has a YEAR(4) type.  The only caveat is that the year has to be in the range of 1901 to 2155.

 

Why should you care?  With the myisam engine, a double column requires 8 bytes, whereas a year only requires 1 byte!  Saving 7 bytes per row for both data and index if needed, is always extremely important to consider for a database of any significant size.

 

Thanks for the info! I will keep that in mind. Unfortunately, I have a decent amount of dates that go back before 1901. But, I will keep this in mind if I can use it for any dates.

 

Qadoshyah

Link to comment
Share on other sites

Even better, MySQL has a YEAR(4) type.  The only caveat is that the year has to be in the range of 1901 to 2155.

 

Why should you care?  With the myisam engine, a double column requires 8 bytes, whereas a year only requires 1 byte!  Saving 7 bytes per row for both data and index if needed, is always extremely important to consider for a database of any significant size.

 

Thanks for the info! I will keep that in mind. Unfortunately, I have a decent amount of dates that go back before 1901. But, I will keep this in mind if I can use it for any dates.

 

Qadoshyah

 

If that is the case, then I'd recommend you use an unsigned smallint.  Only requires 2 bytes, and you will not have any issue with range, as it allows values up to 64k.

Link to comment
Share on other sites

Even better, MySQL has a YEAR(4) type.  The only caveat is that the year has to be in the range of 1901 to 2155.

 

Why should you care?  With the myisam engine, a double column requires 8 bytes, whereas a year only requires 1 byte!  Saving 7 bytes per row for both data and index if needed, is always extremely important to consider for a database of any significant size.

 

Thanks! I tried using smallint and it doesn't work for the date column I tried it on. The date column I tried it on has to have the date like  "1994-10-11." When I do smallint, it only gives the year. No day & month.

 

Qadoshyah

 

Thanks for the info! I will keep that in mind. Unfortunately, I have a decent amount of dates that go back before 1901. But, I will keep this in mind if I can use it for any dates.

 

Qadoshyah

 

If that is the case, then I'd recommend you use an unsigned smallint.  Only requires 2 bytes, and you will not have any issue with range, as it allows values up to 64k.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.