Jump to content

[SOLVED] Field name a number


mrMarcus

Recommended Posts

Hello all,

 

i was just wondering if you are able to use a number (ie. 1) as a field name in a database (MySQL) .. 'cause i tried it and was unable to update the database, but when changing the same field to an alpha-numeric value, the update was successful.

 

if having a numeric value is possible, what do i have to do way of query or setup to allow for that?

 

thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/125672-solved-field-name-a-number/
Share on other sites

The mysql manual (in the Schema Object Names section) tells you how to do this, but a column, like a variable or anything else in programming, should have a name that indicates the use or purpose. Wanting to do this leads us to believe your table is not designed correctly and you will have both problems writing code because the column names won't help and your design is probably not normalized, which will make the code more complicated and run slower than necessary.

i was easily able to change it .. i was just messing around with a calendar script i started writing, and just set up the database initially to be queried directly relating to the numeric value of each month.  Selecting from the db was not a problem when having numeric values for the fields, it was just when updating/inserting into the db that problem arose.

 

wasn't that big a deal, and i never would've set the db up that way had i known it wouldn't work.  so i just simply renamed the fields to their respective months and it works like a beaut.

 

thanks for the replies.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.