Column name with spaces

From SQLZOO
Jump to navigation Jump to search

SELECT a column whose name contains spaces?

schema:scott

You can access columns where the name contains a space.

DROP TABLE SpaceMonster
CREATE TABLE SpaceMonster([Account Balance] INT);
INSERT INTO SpaceMonster VALUES (42);
SELECT [Account Balance] FROM SpaceMonster
CREATE TABLE SpaceMonster(`Account Balance` INT);
INSERT INTO SpaceMonster VALUES (42);
SELECT `Account Balance` FROM SpaceMonster
CREATE TABLE SpaceMonster("Account Balance" INT);
INSERT INTO SpaceMonster VALUES (42);
SELECT "Account Balance" FROM SpaceMonster
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects