Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Bryan Cerrati
Bryan Cerrati
5,880 Points

SQL Confussion

the question is Create a table called "products" with a VARCHAR column named "name", a TEXT column named "description" and a INTEGER "stock_count" column. The name should be up to 100 characters long.

so i type CREATE TABLE products (name VARCHAR(100), description TEXT, stock_count INTERGER);

then the SQL syntax is table already exists so i add IF NOT EXISTS before the table name and i get "Bummer! The types for name, stock_count and/or description are incorrect. Use VARCHAR(100), INTEGER and TEXT respectively."

plix help

4 Answers

Garrett Reasoner
Garrett Reasoner
913 Points

Hey Bryan,

If you make a mistake and don't match the exact syntax Team Treehouse is looking for you can still manage to create the SQL table and any statements following that will fail because the challenge tests seem to create temporary tables (possibly?) to validate the statements. I've ran into the error and just refreshed the page and entered the correct statement the first time and was able to pass the section.

The code to create a table and not pass could be something like:

CREATE TABLE products ( name VARCHAR(75), description TEXT, stock_count INTEGER);

Correct the code to VARCHAR(100) like so:

CREATE TABLE products ( name VARCHAR(100), description TEXT, stock_count INTEGER);

And you'll see this error.

Imgur

Just refresh the page and use the correct statement the first time.

Bryan Cerrati
Bryan Cerrati
5,880 Points

You are 100% corrwct the temporary table was created even if the answer was wrong and the syntax was wrong i assumed since the lesson had discussed IF NOT EXISTS that the error was to advert that warning but it has nothing to do with that yoy just need to get the code correct in the first place to avoid that temp table. Rhank you all soo much! I passed that section and i can now move on properly. Yey

Bryan Cerrati
Bryan Cerrati
5,880 Points

and thank you again garrett

Łukasz Czuliński
Łukasz Czuliński
8,646 Points

You have misspelled "INTEGER" as "INTERGER". Change it and see if it works now.

Bryan Cerrati
Bryan Cerrati
5,880 Points

Its supposed to be integer thou... I thought the same thing that it would be interger but thats how they spell it here.

Bryan Cerrati
Bryan Cerrati
5,880 Points

ive tried INTERGER! no go still displays

Bummer! The types for name, stock_count and/or description are incorrect. Use VARCHAR(100), INTEGER and TEXT respectively.

Łukasz Czuliński
Łukasz Czuliński
8,646 Points

I'm not sure what's happening. Based on the question this code should work:

CREATE TABLE products (name VARCHAR(100), description TEXT, stock_count INTEGER);

I just created a new table with it on my computer.

Marcin Robert Kaźmierczak
Marcin Robert Kaźmierczak
33,570 Points

There is an error. This challenge doesn't work correctly. This SQL definitely work on your computer (on my computer also), but when you put this into answer field you'll have an error.

I found solution. You need to reload your page with CTRL and then do this challenge once again.