ERROR 1103 occurs when MySQL encounters an invalid or empty table identifier in your SQL statement. This is commonly caused by incorrect quoting, special characters, or reserved keywords in table names.
MySQL Error 1103 (ER_WRONG_TABLE_NAME with SQLSTATE 42000) indicates that the database server detected an illegal or empty table identifier in your query. This error signals a syntax problem with how you've specified the table name in your SQL statement. The table name may contain forbidden characters, be empty due to a variable issue, or violate MySQL's naming conventions in other ways. Unlike some errors that reflect missing tables or permission issues, Error 1103 is purely a syntax validation error that prevents the query from executing at all.
Verify that you're using backticks (`) to quote table names, not single quotes (') or double quotes ("). You must use the backtick character, which is different from a regular single quote.
Incorrect:
SELECT * FROM 'users';
SELECT * FROM "orders";Correct:
SELECT * FROM `users`;
SELECT * FROM `orders`;Backticks allow you to use reserved keywords and special characters in table names.
Check for accidental spaces before or after the table name. This is especially common when generating table names dynamically or copy-pasting from logs.
Problematic examples:
CREATE TABLE `users `; -- trailing space
CREATE TABLE ` products`; -- leading space
SELECT * FROM users WHERE id = 1; -- hidden space in nameFix: Trim whitespace from variable values:
const tableName = userInput.trim();
const query = `SELECT * FROM \`${tableName}\``;MySQL reserves many keywords for its SQL syntax. If your table name is a keyword, it must be quoted with backticks.
Reserved keywords that commonly cause this error:
- ORDER, GROUP, TABLE, INDEX
- SELECT, INSERT, UPDATE, DELETE
- USER, COLUMN, KEY, DEFAULT
Incorrect:
SELECT * FROM order;
CREATE TABLE group (id INT);Correct:
SELECT * FROM `order`;
CREATE TABLE `group` (id INT);Table names can only contain letters, digits, underscores, and hyphens. Spaces, slashes, dots, and special Unicode characters are not allowed unless the entire name is quoted with backticks.
Illegal characters:
- Spaces: user profiles
- Hyphens at the start: -users
- Slashes: logs/2025
- Dots: data.backup
Fix with backticks:
-- Spaces require backticks:
SELECT * FROM `user profiles`;
-- Or replace with underscores:
SELECT * FROM user_profiles;
-- Dynamic names with special chars:
const safeTableName = userInput.replace(/[^a-zA-Z0-9_]/g, '_');
const query = `SELECT * FROM \`${safeTableName}\``;MySQL limits table names to 64 characters. While newer versions specifically report "Identifier too long," older MySQL versions returned Error 1103 for overly long names.
Check name length:
SELECT LENGTH('my_very_long_table_name_that_exceeds_sixty_four_characters_limit') as name_length;Solution: Shorten the name or use an alias:
-- Too long (70+ chars):
SELECT * FROM `user_authentication_logs_with_detailed_tracking_information_2025`;
-- Fixed (under 64 chars):
SELECT * FROM `user_auth_logs_2025`;
-- Or with alias:
SELECT * FROM `user_authentication_logs_detailed_2025` AS ual;If your table name comes from a variable or function, print the actual value before using it in the query.
Node.js / JavaScript example:
const tableName = generateTableName(); // from variable or function
console.log('Table name:', tableName);
console.log('Length:', tableName.length);
console.log('Has spaces:', /\s/.test(tableName));
const query = `SELECT * FROM \`${tableName}\``;
db.query(query).catch(err => {
console.error('Query:', query);
console.error('Error:', err.message);
});Python example:
table_name = generate_table_name()
print(f"Table name: '{table_name}'")
print(f"Repr: {repr(table_name)}") # Shows hidden whitespace
query = f"SELECT * FROM `{table_name}`"
cursor.execute(query)The repr() function in Python will display hidden whitespace clearly.
Case sensitivity: On case-sensitive file systems (Linux), MySQL respects table name case. On case-insensitive systems (Windows, macOS by default), table names are folded to lowercase. If you're migrating between systems, ensure your queries use consistent casing.
MariaDB compatibility: This error applies equally to MariaDB, which maintains MySQL compatibility. The same solutions work for both.
ORMs and drivers: When using ORMs like Sequelize, Prisma, or TypeORM, the library should properly escape table names. If you're building dynamic table names, ensure the ORM's escaping functions are used:
- Prisma: Use parameter binding, never string interpolation
- Sequelize: Use sequelize.literal() for custom identifiers
- TypeORM: Use QueryBuilder with proper identifier quoting
Temporary tables: Temporary tables follow the same naming rules. Error 1103 with temporary tables often indicates a variable containing an empty string was used instead of a literal name.
ERROR 1064: You have an error in your SQL syntax
How to fix "ERROR 1064: You have an error in your SQL syntax" in MySQL
ERROR 1054: Unknown column in field list
Unknown column in field list
ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE (3589): RANGE frame requires numeric ORDER BY expression
RANGE frame requires numeric ORDER BY expression in MySQL window functions
CR_ALREADY_CONNECTED (2058): Handle already connected
How to fix "CR_ALREADY_CONNECTED (2058): Handle already connected" in MySQL
ER_WINDOW_DUPLICATE_NAME (3591): Duplicate window name
How to fix ER_WINDOW_DUPLICATE_NAME (3591) in MySQL window functions