Oops! I'm a beginner who made a beginner's error – I have a table with that uses reserved words for field names (the field names are First and ALL).
I am restructuring the database, and want to copy two joined tables to one flat table. I'm using the following SQL structure:
INSERT INTO
new_table_name (field1, field2, field3...)
SELECT
main.filed1, main.field2, ...
subtable.field1, subtable.field2 ... FROM
main INNER JOIN
subtable ON
main.primarykey =
subtable.foreignkey;
The problem is that when the query runs, I get an error message as in running it tries to break up the query at First and ALL. I've tried putting single and double quotes (before the comma) around the words, but other than coloring the text green (I'm using PHPMyAdmin to run the query), I'm still getting an error message.
Quote:
|
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"First", Street1, Street2, City, State, Zip, Phone1, Phone2, Phone3, Email, Pass' at line 1
|
Eventually I will be renaming the fields to FirstName and AllAbove to avoid the problem. However, since the database is live at the moment, I'm hoping to copy to a new table first, THEN make the changes to the underlying PHP code. Any suggestions?
Thanks,
Rhythm