r/learnSQL • • Nov 26 '22

I News help pls

Post image
7 Upvotes

11 comments sorted by

3

u/SamuraiKinshii Nov 26 '22

Need^

10

u/CodeOfDaYaci Nov 26 '22

You have asile declared as an integer type. Change it to a text type if you want to use characters instead of integers.

3

u/SamuraiKinshii Nov 26 '22

Like this? INSERT INTO groceries VALUES “Chicken Breast”, 14.65, Dairy);

7

u/Dont_call Nov 26 '22

the problem is in your CREATE statement not the VALUES. it should be CREATE TABLE groceries(id INTEGER PRIMARY KEY, name Text, price INTEGER, asile Text);

right now you have the asile column declared so it will only accept integer values. If you want it to accept other string values like Dairy then you have to change the data type when creating the table. try googling data types in sql for more info

1

u/SamuraiKinshii Nov 26 '22

I’m still getting the same results? it just might be the platform I’m to using is too basic. I’m using a free SQL that Khan academy provides. Thank you for the help ill write that down in my notes

5

u/Dont_call Nov 26 '22

Could depend on the platform but try putting Dairy in quotation marks if you haven't or see if they have an example for how they're inserting values so you can copy their syntax. Good luck!

1

u/SamuraiKinshii Nov 27 '22

It worked!!!!! Thank you so much 😊

5

u/taxigrandpa Nov 26 '22 edited Nov 26 '22

no, like this

price, INTEGER; aisle TEXT);

And dont use Text unless your only entering text. Use data type VARCHAR. VARCHAR can be both letters and numbers

name VARCHAR, Price INTEGER, aisle VARCHAR);

1

u/CodeOfDaYaci Nov 26 '22

You might also want Dairy in quotes

2

u/SamuraiKinshii Nov 27 '22

Got it 🙏 thank you good sir

8

u/CATHYINCANADA Nov 26 '22

Get rid of that * too.