I have a table in a MySQL table with a fieldname 'product', and want to rename it to 'ds-product'.
The CMS type system I am using uses the id of formfields as the name of the table field to insert into.
For most this works fine, but for a particular field it prepends 'ds-' to whatever ID I give it, so I must make the table field name match.
However, when trying to do a query I get the error that
Unknown column 'sales.ds' in 'field list'
Is there any way I can have a field called ds-product?
PL/SQL supports two comment styles: single-line and multi-line. A double hyphen ( - - ) anywhere on a line (except within a character literal) turns the rest of the line into a comment.
To set a string with hyphen and numbers, you need to use single quotes. For example, 'Customer-1234-899', 'Customer-9383-901', etc.
Rule 1d (Special Characters) - For table names, underscores should not be used. The underscore character has a place in other object names but, not for tables. Using PascalCase for your table name allows for the upper-case letter to denote the first letter of a new word or name.
The desc is a MySQL reserved word, therefore you cannot use it. But, if you still want to set the column name as 'desc', you need to use backticks. The backtick notation is (` `).
Try putting brackets on the last part of your call on the table. in your case:
SELECT * FROM [TABLE-NAME];
just make sure to put the brackets on the table name only. not on the whole database it is located
SELECT * FROM some_database.anotherdatabase.[your-table];
P.S. works on columns, too.
I'm using Microsoft SQL Server Management.
Yes, you can use punctuation, white space, international characters, and SQL reserved words if you use delimited identifiers:
SELECT * FROM `my-table`;
In MySQL, use the back-ticks. In standard SQL, use double-quotes.
Or if you use MySQL you can set the ANSI_QUOTES
SQL mode:
SET SQL_MODE = ANSI_QUOTES; SELECT * FROM "my-table";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With