- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Resolve ERROR 1064 (42000) that occurred after using varchar (without providing the size)
Let us first see when this situation can arise. Create a table and set column name with datatype but without the size −
mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar, LastName varchar ); ERROR 1064 (42000): 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 ', LastName varchar )' at line 4
You can correct the above error by providing the size for varchar data type like varchar(100). The same will fix the issue.
Let’s fix it and at first create a table −
mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(FirstName,LastName) values('Adam','Smith'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable(FirstName,LastName) values('John','Doe'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable(FirstName,LastName) values('Chris','Brown'); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+-----------+----------+ | Id | FirstName | LastName | +----+-----------+----------+ | 1 | Adam | Smith | | 2 | John | Doe | | 3 | Chris | Brown | +----+-----------+----------+ 3 rows in set (0.00 sec)
- Related Articles
- Resolve MySQL ERROR 1064 (42000): You have an error in your syntax?
- Fix ERROR 1064 (42000) while creating a database in MySQL?
- Resolve usage of quotes ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use?
- ERROR 1064 (42000): You have an error in your SQL syntax at zero fill column?
- How to resolve the ERROR 1115 (42000): Unknown character set: 'utf8mb4'?
- Fix MySQL ERROR 1064 (42000) check the manual that corresponds to your MySQL server version for the right syntax to use near ')'
- Fix MySQL Database Error #1064?
- How to add duplicate varchar values without displaying error in MySQL?
- What is the common error occurred while using scanf() statement in C language?
- Resolve the MySQL error 'TYPE=MyISAM'?
- How to resolve the error that occurs while using a reserved word as a table or column name in MySQL?
- Error 1046 No database Selected, how to resolve?
- What is the MySQL VARCHAR max size?
- Fix MySQL Error #1064 - You have an error in your SQL syntax… near 'TYPE=MyISAM?
- Resolve Unknown database in JDBC error with Java-MySQL?

Advertisements