Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

derby sql insert

Tags:

sql

derby

I'm trying to insert values in my database This is the statement I try to execute:

insert into leverancier (id,naam,straat,nr,postcode,plaats,telefoon) 
    values (1,"stef","bosstraat",88,9240,"Zele",null);

I get the following error:

ERROR 42X04: Column 'stef' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'stef' is not a column in the target table.

What is the problem?

like image 431
user999379 Avatar asked Dec 13 '22 05:12

user999379


1 Answers

To insert a string, like "stef", don't use double quotes but single quotes: 'stef'. Here's how the statement should be:

INSERT INTO leverancier 
  (id, naam, straat, nr, postcode, plaats, telefoon) 
VALUES 
  (1,'stef', 'bosstraat', 88, 9240, 'Zele', NULL);

The error you get Column 'stef' is either not in any table ... is because double quotes are used for table and column names. So reading "stef", the parser assumes you are referring to a column named stef.

like image 106
ypercubeᵀᴹ Avatar answered Jan 03 '23 21:01

ypercubeᵀᴹ