SELECT COMMAND SQL超过1个值

时间:2012-03-29 11:58:05

标签: sql

我试图创建一个select命令来查询我拥有的数据库,并从数据库中的不同表中查找不同的值。

1 个答案:

答案 0 :(得分:3)

尝试以下操作,我将所有ID列从CHAR更改为NUMBER

CREATE TABLE Actor
(actorID NUMBER,
lastName CHAR(24),
firstName CHAR(24),
middleName CHAR(24),
suffix CHAR(6),
gender CHAR(1),
birthDate DATE,
deathDate DATE)
/

CREATE TABLE Movie
(movieID NUMBER,
title CHAR(36),
year NUMBER,
company CHAR(50),
totalNoms NUMBER,
awardsWon NUMBER,
DVDPrice NUMBER(5,2),
discountPrice NUMBER(5,2))
/

CREATE TABLE Role
(roleID NUMER,
roleName CHAR(36),
gender CHAR(1),
actorID NUMBER,
movieID NUMBER)
/

CREATE TABLE Quote
(quoteID NUMBER,
quoteCHAR CHAR(255))
/

CREATE TABLE RoleQuote
(roleID NUMBER,
quoteID NUMBER)
/

,选择将是:

SELECT  Movie.Title , Movie.Year , Actor.Firstname, Actor.lastname, Role.roleName, Quote.quoteCHAR 
FROM    Movie, Actor, Role, Quote, RoleQuote
WHERE   Movie.movieID = Role.movieId AND 
    Actor.actorID = Role.ActorId AND 
    Role.roleID = RoleQuote.roleID AND
    Quote.quoteID = RoleQuote.quoteID AND
    Quote.quoteCHAR LIKE '%Houston, we have a problem.%'