I am using SQlite3 in Visual Studio code. My goal is to create a table within a database and then import data in that table. The code works fine except for when there is a space involved in the header. The header for the column is "Order ID". When I get rid of the space and import the data it works fine but when I use the space it inputs "order ID" into every spot. Below is the code I am using.
CREATE TABLE Returnedsss
(
Returned Text ,
‘Order ID’ Text ,
PRIMARY KEY (‘Order ID’)
)
;
.tables
.mode csv
.separator ,
.import –csv "C://Business_Analytics//SQlite//data//Returns.csv" Returnedsss
SELECT ‘Order ID’
FROM Returnedsss;
I tried the above and the output is
"Order ID"
"Order ID"
"Order ID"
"Order ID"
When I change it to get rid of the space though and run this code though it runs fine and gives me the Order IDs as an output:
CREATE TABLE Returnedsss
(
Returned Text ,
OrderID Text ,
PRIMARY KEY (OrderID)
)
;
.tables
.mode csv
.separator ,
.import –csv "C://Business_Analytics//SQlite//data//Returns.csv" Returnedsss
SELECT OrderID
FROM Returnedsss;
Is there a way to do it where it lets me use the Order ID instead of having to do OrderID?
2
Answers
I figured out the issue. I was using ' and I needed to use `
Use
or
The issue is how single quotes are used to enclose a literal value character string in preference to enclosing a component name (column table etc).