Re: I can"t have "group" as a column name in a table?
am 24.02.2011 12:24:40 von Simcha
On Thu, 24 Feb 2011 16:43:56 +0530
Aveek Misra wrote:
> Use a quote around the column name or explicitly specify the column as . (as for e.g. mytable.group) in the query. For more details refer to http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
>
use backticks, not quotes.
`group`, not 'group'.
--
Simcha Younger
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org
Re: I can"t have "group" as a column name in a table?
am 24.02.2011 13:02:50 von Johan De Meersman
--001517475e6e236c84049d05feae
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Feb 24, 2011 at 12:06 PM, Dave M G wrote:
> Should I never use the word "group" for column names? Seems a little
> silly. Is there a way to protect column names to that there is no
> confusion?
>
As several people already pointed out, simply use backticks. Simple quotes
have started to work in more and more places in newer versions of MySQL.
However, it is considered bad form to name columns for reserved words - even
ones as obvious as "group" or "index". Bad form in the same way that you
wouldn't name any variables "define" or "if" while programming; or in a very
similar way that you wouldn't put a box of TNT next to a burning candle -
it's an accident waiting to happen.
The escapes are there in case an upgrade creates new reserved words that
you've already used in column names - "partition" comes to mind - but if you
are still in a phase where you can avoid using reserved words, please spare
yourself and others a lot of trouble and do so; even if only because while
you can fix your code, you can't fix someone else's - think management
tools, backup scripts, whatever may touch the db in the future.
--
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel
--001517475e6e236c84049d05feae--
Re: I can"t have "group" as a column name in a table?
am 24.02.2011 13:30:07 von joao
The best comparison I´ve never seen in my life was the TNT.
LOL
--
João Cândido de Souza Neto
"Johan De Meersman" escreveu na mensagem
news:AANLkTikPeVuTpj9E0iepFncCJZQOF6sn_dbrhp0=pTDF@mail.gmai l.com...
> On Thu, Feb 24, 2011 at 12:06 PM, Dave M G wrote:
>
>> Should I never use the word "group" for column names? Seems a little
>> silly. Is there a way to protect column names to that there is no
>> confusion?
>>
>
> As several people already pointed out, simply use backticks. Simple quotes
> have started to work in more and more places in newer versions of MySQL.
>
> However, it is considered bad form to name columns for reserved words -
> even
> ones as obvious as "group" or "index". Bad form in the same way that you
> wouldn't name any variables "define" or "if" while programming; or in a
> very
> similar way that you wouldn't put a box of TNT next to a burning candle -
> it's an accident waiting to happen.
>
> The escapes are there in case an upgrade creates new reserved words that
> you've already used in column names - "partition" comes to mind - but if
> you
> are still in a phase where you can avoid using reserved words, please
> spare
> yourself and others a lot of trouble and do so; even if only because while
> you can fix your code, you can't fix someone else's - think management
> tools, backup scripts, whatever may touch the db in the future.
>
>
> --
> Bier met grenadyn
> Is als mosterd by den wyn
> Sy die't drinkt, is eene kwezel
> Hy die't drinkt, is ras een ezel
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org
Re: I can"t have "group" as a column name in a table?
am 24.02.2011 16:35:13 von mos
At 05:13 AM 2/24/2011, you wrote:
>Use a quote around the column name or explicitly specify the column as
>
. (as for e.g. mytable.group) in the query. For more
>details refer to http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
>
>Thanks
>Aveek
Hmmm. Everyone has given me a great idea. I am going to change my table
names to "Table", "Group", "Having", "Select", "Into", "Order By",
"Update", "Delete" etc. just to confuse hackers so they won't be able to
launch a sql injection attack against my website. The naming convention
will drive them crazy.
Mike
(Just kidding)
>On Feb 24, 2011, at 4:36 PM, Dave M G wrote:
>
> > MySQL users,
> >
> > Simple question:
> >
> > In one table in my database, the column was named "group".
> >
> > I kept getting failed query errors until I renamed the column.
> >
> > I've never before encountered a situation where MySQL mistook a column
> > name for part of the query syntax.
> >
> > Should I never use the word "group" for column names? Seems a little
> > silly. Is there a way to protect column names to that there is no
> confusion?
> >
> > --
> > Dave M G
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe: http://lists.mysql.com/mysql?unsub=aveekm@yahoo-inc.com
> >
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org
Re: I can"t have "group" as a column name in a table?
am 24.02.2011 16:48:02 von joao
LOL
--
João Cândido de Souza Neto
"mos" escreveu na mensagem
news:6.0.0.22.2.20110224093057.044a0598@mail.messagingengine .com...
> At 05:13 AM 2/24/2011, you wrote:
>>Use a quote around the column name or explicitly specify the column as
>>. (as for e.g. mytable.group) in the query. For more
>>details refer to
>>http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
>>
>>Thanks
>>Aveek
>
> Hmmm. Everyone has given me a great idea. I am going to change my table
> names to "Table", "Group", "Having", "Select", "Into", "Order By",
> "Update", "Delete" etc. just to confuse hackers so they won't be able to
> launch a sql injection attack against my website. The naming convention
> will drive them crazy.
>
> Mike
> (Just kidding)
>
>
>
>>On Feb 24, 2011, at 4:36 PM, Dave M G wrote:
>>
>> > MySQL users,
>> >
>> > Simple question:
>> >
>> > In one table in my database, the column was named "group".
>> >
>> > I kept getting failed query errors until I renamed the column.
>> >
>> > I've never before encountered a situation where MySQL mistook a column
>> > name for part of the query syntax.
>> >
>> > Should I never use the word "group" for column names? Seems a little
>> > silly. Is there a way to protect column names to that there is no
>> confusion?
>> >
>> > --
>> > Dave M G
>> >
>> > --
>> > MySQL General Mailing List
>> > For list archives: http://lists.mysql.com/mysql
>> > To unsubscribe:
>> > http://lists.mysql.com/mysql?unsub=aveekm@yahoo-inc.com
>> >
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org
Re: I can"t have "group" as a column name in a table? [SOLVED]
am 25.02.2011 15:17:13 von Dave M G
Aveek, Simcha, Johan,
Thanks for explaining the situation. I knew there were some reserved
words, but I hadn't realized there were so many.
Anyway, now that I know I can protect my column names with backticks,
I'm good to go.
--
Dave M G
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org