sql语句中and和or怎么同时使用
1、创建测试表,
create table test_andor(id number, value varchar2(200));
2、插入样例数据,
insert into test_andor values(1,1001);
insert into test_andor values(2,1002);
insert into test_andor values(3,1003);
insert into test_andor values(4,1004);
insert into test_andor values(5,1005);
3、查看表中所有记录 select * from test_andor,
4、编辑sql,涵盖and 和 or的条件,如,id为3或4,同时value=1003,注意or条件要用括号括起来。
select t.*, rowid from test_andor t where (id = 3 or id = 4) and value = 1004
sql怎么选择数据and和or能同时用吗???
and和or能同时使用。
如下参考:
1.创建一个测试表Createtabletest_andor(idnumber,valuevarchar2(200)),如下图。
2.插入示例数据Insertintotest_andorvalues(11001);Insertintotest_andorvalues(2100);
Insertintotest_andorvalues(31003);Insertintotest_andorvalues(4100);Insertintotest_andorvalues(5100);
3.查看表select*fromtest_andor中的所有记录,如下图。
4.编辑SQL,包括and和or条件,如id为3或4,value=1003,注意or条件应该用圆括号括起来选择t。*,rowidfromtest_andortwhere(id=3orid=4)andvalue=1004。