0

Hi there, i am using sqlite3 online compiling. I wanted to create a table where one of the employee has a value of unknown salary.
Here are my sqlite3 codes.

where John Doe works at Burger Steak but his salary is unknown.

BEGIN TRANSACTION;
/* Create a table called Works */
CREATE TABLE Works(employee_name text, company_name text, salary varchar);

/* Create few records in this table */
INSERT INTO Works VALUES('John Smith', 'Starbucks Coffee', '2000 USD');
INSERT INTO Works VALUES('Peter Cruz', 'Mc Donalds', '3000 USD');
INSERT INTO Works VALUES('John Doe', 'Burger Steak', '');
COMMIT;

The output is

John Smith|Starbucks Coffee|2000 USD
Peter Cruz|Mc Donalds|3000 USD
John Doe|Burger Steak|

Am i doing this right? Is the unknown salary should be leave blank? what about NULL values, how i could apply it here.

2
Contributors
3
Replies
14
Views
2 Years
Discussion Span
Last Post by hericles
3

You aren't entering a NULL value for John Doe, you're entering an empty string which is not the same as NULL.
INSERT INTO Works VALUES('John Doe', 'Burger Steak', null);

would result in
John Doe | Burger Steak | NULL

0

thank you so much i think that is the statement im searching for. I've been trying also

INSERT INTO Works (
    employee_name,
    company_name,
    salary
) VALUES (
    'John Doe',
    'Burger Steak',
    'NULL'
);

i was wrong in putting qoute. thank you so much for the enlightenment

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.