Hello,

I am brushing-up on SQL (using MySQL). It has been many years since I have worked with this and I'm having some trouble getting started.

I have looked at a tutorial and entered the code below:

CREATE TABLE employees (              
             employeeNumber into(11) NOT NULL,    
             lastName varchar(50) NOT NULL,      
             firstName varchar(50) NOT NULL,     
             extension varchar(10) NOT NULL,     
             email varchar(100) NOT NULL,        
             officeCode varchar(10) NOT NULL,    
             reportsTo int(11) default NULL,     
             jobTitle varchar(50) NOT NULL,      
             PRIMARY KEY  (employeeNumber)       
           );

I receive the error message in return:

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 
'juggernaut
CREATE TABLE employees (
             employeeNumber in' at line 1

I am not quite sure what the message is referring to - I assumed it should run just fine.
If I remove the "employeeNumber into(11) NOT NULL," line completely the same error message returns for the next line.

I'm puzzled. :confused:

Thank-you in advance for any guidance in the right direction.

-Matty

Recommended Answers

All 8 Replies

Hi

>>> if I remove the "employeeNumber into(11) NOT NULL," line completely the same error message returns for the next line.


Be that as it may, "into(11)" isn't a datatype --> int(11) seems to be correct.

-- tesu

Hi

>>> if I remove the "employeeNumber into(11) NOT NULL," line completely the same error message returns for the next line.


Be that as it may, "into(11)" isn't a datatype --> int(11) seems to be correct.

-- tesu

I make changes per your suggestion. Please see attached image of results. Thanks.

Worked fine for me in the MySQL monitor in terminal.

mysql> CREATE TABLE employees (              
    ->              employeeNumber int(11) NOT NULL,    
    ->              lastName varchar(50) NOT NULL,      
    ->              firstName varchar(50) NOT NULL,     
    ->              extension varchar(10) NOT NULL,     
    ->              email varchar(100) NOT NULL,        
    ->              officeCode varchar(10) NOT NULL,    
    ->              reportsTo int(11) default NULL,     
    ->              jobTitle varchar(50) NOT NULL,      
    ->              PRIMARY KEY  (employeeNumber)       
    ->            );
Query OK, 0 rows affected (0.10 sec)

Worked fine for me in the MySQL monitor in terminal.

mysql> CREATE TABLE employees (              
    ->              employeeNumber int(11) NOT NULL,    
    ->              lastName varchar(50) NOT NULL,      
    ->              firstName varchar(50) NOT NULL,     
    ->              extension varchar(10) NOT NULL,     
    ->              email varchar(100) NOT NULL,        
    ->              officeCode varchar(10) NOT NULL,    
    ->              reportsTo int(11) default NULL,     
    ->              jobTitle varchar(50) NOT NULL,      
    ->              PRIMARY KEY  (employeeNumber)       
    ->            );
Query OK, 0 rows affected (0.10 sec)

Thank-you for your reply. :) It's odd, I do this in the MySQl Terminal and keep getting the same error.

I'm new to MySQL, so pardon the dumb question, but what does the word 'juggernaut' mean when it appears immediately before your CREATE statement (as shown in your attached thumbnail)?

I'm new to MySQL, so pardon the dumb question, but what does the word 'juggernaut' mean when it appears immediately before your CREATE statement (as shown in your attached thumbnail)?

"juggernaut" is the name of my database.

should be

use juggernaught;

should be

use juggernaught;

Thank-you for pointing this out. :icon_wink:

-Matty

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.