How to fix ERROR 1103: Incorrect table name in MySQL
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.
Quick fix
Fixes 1103
SELECT * FROM 'users';
SELECT * FROM "orders";- Check for incorrect quote characters
- Inspect the table name for whitespace
- Verify table names do not use reserved keywords without quoting
- Remove illegal characters from table names
SELECT * FROM 'users';SELECT * FROM "orders";ERROR 1103: Incorrect table name
What this error means
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.
Typical symptoms
- Query fails immediately with "Incorrect table name" message
- CREATE TABLE, INSERT, SELECT, or UPDATE statements stop execution
- No partial results are returned - the entire query is rejected
- Error appears when using dynamically generated table names from variables
- Works in one environment but fails in another with identical code
Common causes
- Using single quotes instead of backticks around table names (e.g., SELECT * FROM 'users' instead of SELECT * FROM `users`)
- Table name contains trailing or leading whitespace (e.g., `users ` with a space after)
- Table name includes illegal characters like spaces, hyphens, slashes, or Unicode symbols without proper quoting
- Table name is a reserved MySQL keyword (ORDER, GROUP, TABLE, INDEX, SELECT) and is not quoted with backticks
- Table name exceeds 64 characters (older versions returned "Incorrect table name" instead of "Identifier too long")
- Empty string passed as table name, often from string concatenation bugs or uninitialized variables
- Table name starts with a digit without being quoted (e.g., 2023_records instead of `2023_records`)
- Mixed quote styles in a single identifier (e.g., backtick and single quote together)
How to fix "ERROR 1103: Incorrect table name"
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.
Advanced notes
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.
Frequently asked questions
- What does "1103" mean?
- 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.
- How do I fix "1103"?
- 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.
- What causes "1103"?
- Using single quotes instead of backticks around table names (e.g., SELECT FROM 'users' instead of SELECT FROM users) Table name contains trailing or leading whitespace (e.g., users with a space after) Table name includes illegal characters like spaces, hyphens, slashes, or Unicode symbols without proper quoting
- Is the "1103" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐MySQL Official Documentation
- ๐MySQL 8.0 Error Reference(Official Docs)
- ๐MariaDB Knowledge Base - Error 1103(Official Docs)
- ๐MySQL Bug #25168 - Incorrect table name error(Official Docs)