大家好,我正在使用Oracle 10g使用Oracle数据库。我有2张桌子 汽车和拥有。
jdbcTemplate.query(
"select id,image,mimetype from images",
(rs,rowNum)-> {
createThumbnail(new ImageHolder(
rs.getInt("id"),
rs.getBytes("image"),
rs.getString("mimetype") ));
})
)
我插入了这些值
Create Table Car(
"license" varchar(255) not null primary key,
"year" varchar(255),
"model" varchar(255)
);
这是Owns表
insert into Car values('12-3000', '2012', 'Axio');
insert into Car values('11-3000', '2008', 'Corolla');
insert into Car values('12-4000', '2013', 'Axio');
insert into Car values('12-5000', '2013', 'Premio');
insert into Car values('11-5000', '2010', 'Nano');
insert into Car values('11-6000', '2011', 'Alto');
insert into Car values('12-6000', '2015', 'Nano Twist');
我也插入了这些值
Create Table Owns (
"nid" varchar(20) not null,
"license" varchar(255),
primary key("nid", "license")
);
现在我需要找到那些拥有“Axio”模特的人的国家身份证(nid)。 怎么写那个查询? 可能是这种......
insert into Owns values('123451', '11-3000');
insert into Owns values('123452', '12-4000');
insert into Owns values('123453', '12-5000');
insert into Owns values('123454', '11-5000');
insert into Owns values('123455', '11-6000');
insert into Owns values('123456', '12-6000');
insert into Owns values('123457', '12-3000');
先谢谢。
答案 0 :(得分:1)
试试这个,
从拥有“许可证”IN的Owns中选择“nid”(从Car中选择“牌照”,其中“model”='Axio');
您也可以尝试使用连接...