Create column with ampersand '&' in MySQL

Hey Guys,
I’m trying to create a new column containing and ampersand(&) in a table in a MySQL database w/o success.
This is the error returned from db.ErrorMessage

There’s something fishy with the "&"…

I’m using a PreparedStatement like this:

          ps = db.Prepare("ALTER TABLE usage ADD ? INT(11) NOT NULL")
          ps.BindType(0, MySQLPreparedStatement.MYSQL_TYPE_STRING)
          ps.Bind(0, "B&W")
          ps.SQLExecute

Any ideas? :slight_smile:

Happy new Y!

See here and try it without the prepared statement using backticks:

db.SQLExecute( "ALTER TABLE usage ADD `B&W` INT(11) NOT NULL" )

(I haven’t tried this so let us know.)

[quote=55938:@Kem Tekinay]See here and try it without the prepared statement using backticks:

db.SQLExecute( "ALTER TABLE usage ADD `B&W` INT(11) NOT NULL" )

(I haven’t tried this so let us know.)[/quote]

Thank you Kem,
It works like a charm now :slight_smile:

I’d recommend you not use special characters in column/table names. It could cause problems later on when you have to continually remember to treat this column differently than all the others.