如果我有两张这样的表:
CREATE TABLE Director
(
`DirectorNr` INTEGER NOT NULL,
`First Name` VARCHAR (20),
`Last Name` VARCHAR (30),
`Age` INTEGER,
`Movies` INTEGER,
PRIMARY KEY(DirectorNr)
);
CREATE TABLE Movies
(
`MovieNr` INTEGER NOT NULL,
`Title` VARCHAR (100),
`Genre` VARCHAR (30),
`USK` INTEGER,
`Director` INTEGER NOT NULL,
`Length` INTEGER,
`Release` DATE,
PRIMARY KEY (MovieNr),
FOREIGN KEY (Director)
REFERENCES Director (DirectorNr)
);
INSERT INTO Director
VALUES (1, 'Peter', 'Jackson', 52, 17);
INSERT INTO Movies
VALUES (1, 'The Hobbit: An Unexpected Journey', 'Fantasy', 12, 1, 169, '2012/12/12');
如何以这种格式获取日期(发布):dd.mm.yyyy
带有SELECT查询?
我已经尝试了这个https://stackoverflow.com/a/24292832,但它对我不起作用。
是否也可以将日期设为dd.mm.yyyy
?
答案 0 :(得分:1)
答案 1 :(得分:1)
试试这个;)
INSERT INTO Movies
VALUES (1, 'The Hobbit: An Unexpected Journey', 'Fantasy', 12, 1, 169,
STR_TO_DATE('2012/12/12', '%Y/%m/%d'));
和SELECT:
SELECT FORMAT(`Release`, '%d.%m.%Y') FROM Movies