数据库被称为“学校”。 'school'有'classroom_names'表,即'room1'作为表,'room2'作为另一个表等,每个'classroom_names'都有'student_name'列。
我想选择所有'classroom_names',其中有一个名为'John'的'student_name'。
到目前为止,我只能从数据库中选择所有'classroom_names',如:
select * from syscat.tables
答案 0 :(得分:2)
我建议如下。 (试图解决你的设计中的一些问题)
创建以下视图
CREATE OR REPLACE VIEW SCHOOL.STUDENT_LIST AS
SELECT 'Room1' as CLASSROOM, student_name FROM SCHOOL.Room1
UNION ALL
SELECT 'Room2' as CLASSROOM, student_name FROM SCHOOL.Room2
UNION ALL
SELECT 'Room3' as CLASSROOM, student_name FROM SCHOOL.Room3
UNION ALL
SELECT 'Room4' as CLASSROOM, student_name FROM SCHOOL.Room4
UNION ALL
-- etc
SELECT 'RoomN' as CLASSROOM, student_name FROM SCHOOL.RoomN
现在你可以说
SELECT CLASSROOM FROM STUDENT_LIST WHERE student_name = 'John'
答案 1 :(得分:0)
您可以从DB2目录
构建动态查询.nav {
display:block;
min-width:100%;
text-align: left;
position:fixed;
top:0; left:0;
list-style-type:none;
z-index:1000;
margin:0 auto;
background: -webkit-linear-gradient(top left, #3c8dbc 0%, #307196 100%);
background: linear-gradient(to bottom right, #3c8dbc 0%, #307196 100%);
color:#A3A3A3;
height:10%;
font-weight:lighter;
overflow:hidden;
}
.nav li {
display: inline-block;
margin:1%;
height:3%;
list-style-type:none;
color:#A3A3A3;
}
.nav ul{
list-style-type:none;
}
.nav ul li{
list-style-type:none; color:white;
}
最后一部分(db2 + p -tv)允许执行输出。如果它不起作用(缓冲区大小),只需删除它,然后复制粘贴输出。