mrMarcus Posted September 24, 2008 Share Posted September 24, 2008 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. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 24, 2008 Share Posted September 24, 2008 99% sure that you can't. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted September 24, 2008 Author Share Posted September 24, 2008 thanks for the reply... ya, it's not really looking like it's possible .. can't seem to find any info on it anywhere. if anybody knows this for sure, or has a work-around for the use of numeric field names, please let me know. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 24, 2008 Share Posted September 24, 2008 My question is why would you want to do this? I'm struggling to come up with a good reason to do so. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 24, 2008 Share Posted September 24, 2008 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 25, 2008 Share Posted September 25, 2008 A table or column name may begin with a number but not consist solely of numbers Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted September 25, 2008 Author Share Posted September 25, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.