How to fix ERROR 1103: Incorrect table name in MySQL

MySQLBEGINNERMEDIUMUpdated Dec 22, 2025ยท 123 views

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";
  1. Check for incorrect quote characters
  2. Inspect the table name for whitespace
  3. Verify table names do not use reserved keywords without quoting
  4. Remove illegal characters from table names
mysql โ€” error
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

  1. Using single quotes instead of backticks around table names (e.g., SELECT * FROM 'users' instead of SELECT * FROM `users`)
  2. Table name contains trailing or leading whitespace (e.g., `users ` with a space after)
  3. Table name includes illegal characters like spaces, hyphens, slashes, or Unicode symbols without proper quoting
  4. Table name is a reserved MySQL keyword (ORDER, GROUP, TABLE, INDEX, SELECT) and is not quoted with backticks
  5. Table name exceeds 64 characters (older versions returned "Incorrect table name" instead of "Identifier too long")
  6. Empty string passed as table name, often from string concatenation bugs or uninitialized variables
  7. Table name starts with a digit without being quoted (e.g., 2023_records instead of `2023_records`)
  8. Mixed quote styles in a single identifier (e.g., backtick and single quote together)

How to fix "ERROR 1103: Incorrect table name"

1Check for incorrect quote characters

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:

sql
SELECT * FROM 'users';
SELECT * FROM "orders";

Correct:

sql
SELECT * FROM `users`;
SELECT * FROM `orders`;

Backticks allow you to use reserved keywords and special characters in table names.

2Inspect the table name for whitespace

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:

sql
CREATE TABLE `users `;      -- trailing space
CREATE TABLE ` products`;    -- leading space
SELECT * FROM users WHERE id = 1;  -- hidden space in name

Fix: Trim whitespace from variable values:

javascript
const tableName = userInput.trim();
const query = `SELECT * FROM \`${tableName}\``;
3Verify table names do not use reserved keywords without quoting

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:

sql
SELECT * FROM order;
CREATE TABLE group (id INT);

Correct:

sql
SELECT * FROM `order`;
CREATE TABLE `group` (id INT);
4Remove illegal characters from table names

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:

sql
-- 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}\``;
5Ensure table name length is within 64 character limit

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:

sql
SELECT LENGTH('my_very_long_table_name_that_exceeds_sixty_four_characters_limit') as name_length;

Solution: Shorten the name or use an alias:

sql
-- 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;
6Debug dynamically generated table names

If your table name comes from a variable or function, print the actual value before using it in the query.

Node.js / JavaScript example:

javascript
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:

python
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