Introduction to SQL 5 of 11


#1

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:


#2

I am completely new to SQL, I am following the tutorials but have hit a brick wall. I will list the errors first, then list the code I am trying to get working, I hope someone will explain where I am going wrong.

Error: near line 1: near “INSERT”: syntax error
Error: near line 6: no such table: celebs
Error: near line 9: no such table: celebs
Error: near line 12: no such table: celebs


Introduction to SQL

1

CREATE TABLE celebs

2

3

INSERT INTO celebs (id, name, age)

4

VALUES (1, ‘Justin Bieber’, 22);

5

6

INSERT INTO celebs (id, name, age)

7

VALUES (2, ‘Beyonce Knowles’, 33);

8

9

INSERT INTO celebs (id, name, age)

10

VALUES (3, ‘Jeremy Lin’, 26);

11

12

INSERT INTO celebs (id, name, age)

13

VALUES (4, ‘Taylor Swift’, 26);

14

I hope someone will help with this.

Regards, Rod


#3

I think you might be missing a part of this. I haven’t done the course myself, but the structure for this is:

CREATE TABLE tableName (
    columnA datatype,
    columnB datatype,
    columnC datatype
);

And Codecademy is strict with syntax, so remember the “;” at the end of the create table statement.


#4

Thank you for your answer louwding, I will revisit the course and give it a shot, I will report back here how things turn out.

Regards,

Rod

#5
CREATE TABLE celebs (

id INTEGER,

name TEXT,

age INTEGER

);

INSERT INTO celebs (id, name, age)

VALUES (1, 'Justin Bieber', 22);

INSERT INTO celebs (id, name, age)

VALUES (2, 'Beyonce Knowles', 33);

INSERT INTO celebs (id, name, age)

VALUES (3, 'Jeremy Lin', 26);

INSERT INTO celebs (id, name, age)

VALUES (4, 'Taylor Swift', 26);

</quote>

I expected 3 columns.... id   name    age

what I got was 3 rows, nothing was added to the database.

There were no errors, however.

<quote>

Database Schema

celebs4 rows
id
INTEGER
name
TEXT
age
INTEGER

</quote>