1

I created a table with 3 columns ID (Primary key), when (some varchar value), Created_date(timestamp)

Will naming a field with "When" creates any issue?

I have been querying like update table set table.when='$when' where ID='1'

Please suggest

Ramaraju.d
  • 1,301
  • 6
  • 26
  • 46

1 Answers1

7

it's ok as long as you have to use the tableName along with the column name

update `table` 
set `table`.when='$when' 
where ID='1'

otherwise, wrap it with backticks

update `table` 
set `when`='$when' 
where ID='1'

Other Link:

if possible don't use names or identifiers which are on the reserved keyword list to avoid problems.

John Woo
  • 258,903
  • 69
  • 498
  • 492
  • if i make sure that i place a back ticks as 'when', code will not be effected right? By mistake i have added system reserved keyword. Thanks for your reply @JW – Ramaraju.d Feb 01 '13 at 08:59
  • yes but be sure that you will use backticks and not singe quotes. `:D` – John Woo Feb 01 '13 at 09:08