var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Naming columns with numbers
I am pretty new to MySQL and the only previous database use I have had is Access way back in school, so apologise if this is a seriously silly question.
I have created a table named mq1. Within which I have created 11 fields/columns: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, & 10.
How do I get all the information from column named '0'?
I tried the standard querying from the tutorial books:
SELECT 0 FROM mq1 (column 0 from mq1 actually contains one entry: "hello" but this query doesn't return "hello", it returns '0'.)
If I rename column '0' to 'a' and try the query again:
SELECT a FROM mq1 (it returns "hello", which is what i want if I name the column 0)
Do I need to escape the 0 somehow as it is a number? Or is it just not possible to name columns by numbers?
Any help would be very much appreciated here. Thanks,
I'd just recreate your table with proper named fields that explain perfectly what data they hold. You can also rename fields using the alter table command.
You should definitely follow Mike's advice about proper naming of objects/attributes. Though to answer your first question try:
SELECT "0" ....
Naming fields with proper names will make it easier for you to develop later on. However, that is not to say what you are looking for cannot be done. Try the following
CREATE TABLE tablename
(`0` VARCHAR(100), ....);
It also means that when you are writing your SELECT statements that you will need to include the ` as follows:
SELECT `0` FROM tablename;