比如我有张表数据如下
index name type0 A CA0 A CB0 A CB1 B CA1 B CA1 B CA
现在我要写个SQL语句 查出index为0,name为B的所有记录 我的想法是select * from table where index = 0 or name = 'A'; 请各位指点下
index name type0 A CA0 A CB0 A CB1 B CA1 B CA1 B CA
现在我要写个SQL语句 查出index为0,name为B的所有记录 我的想法是select * from table where index = 0 or name = 'A'; 请各位指点下
解决方案 »
- varchar2 读入后带空格
- ORACE-01467 sort key too long
- [Forms]Oracle Forms排序分頁的問題(order by的位置與動態游標)(俺結帖率很高滴)
- sql ——语句
- 各位高手,下面的存储过程错在哪了?解决马上散分,先谢谢了
- 怎么样得到局域网上所有装有Oracle数据库的机器列表呀?
- oracle 安装的错误
- 求主oracle书籍
- 这两个动态sql语句的异常怎么加?(急,在线等待)
- 会话中的“长时间操作”是什么意思?
- sqlldr中插入数据时为何在数据库中的数据出现空行
- 在PL/SQL中写一个function函数,在测试时输原字符串 11;22;33;e4 以分号为分隔符的字符串,例如我需要取第一个,得到的值应该为11
或的关系:select * from table where index = 0 or name = 'A';
并且的关系:select * from table where index = 0 and name = 'B';2、查出index为0,或name为B的所有记录
或的关系:select * from table where index = 0 or name = 'B';
index name type
0 A
0 A
0 A
1 B
1 B
1 B
不知道我说清没 SQL怎么写 表本来记录我只是写了部分
0 A
0 A
0 A
的话就是where index = 0 and name = 'A'是吗
/*
是你想得到什么的结果,看看OR/AND 执行吧
*/
SQL> with t as(
2 select 0 IND,'A' name,'CA' type from dual
3 union all
4 select 0 IND,'A' name,'CB' type from dual
5 union all
6 select 0 IND,'A' name,'CB' type from dual
7 union all
8 select 1 IND,'B' name,'CA' type from dual
9 union all
10 select 1 IND,'B' name,'CA' type from dual
11 union all
12 select 1 IND,'B' name,'CA' type from dual)
13 select * from t where IND=0 or name='B';
IND NAME TYPE
---------- ---- ----
0 A CA
0 A CB
0 A CB
1 B CA
1 B CA
1 B CA
6 rows selected
SQL>
SQL> with t as(
2 select 0 IND,'A' name,'CA' type from dual
3 union all
4 select 0 IND,'A' name,'CB' type from dual
5 union all
6 select 0 IND,'A' name,'CB' type from dual
7 union all
8 select 1 IND,'B' name,'CA' type from dual
9 union all
10 select 1 IND,'B' name,'CA' type from dual
11 union all
12 select 1 IND,'B' name,'CA' type from dual)
13 select * from t where IND=0 AND name='B';
IND NAME TYPE
---------- ---- ----
SQL>