and y or en sentencia select
TRANSCRIPT
Erik SacreBases de Datos
Ejemplo de And y Or
Erik Sacre
Erik SacreBases de Datos
NULLNULLNULLNULL
NULLFALSENULLFALSE
FALSEFALSEFALSEFALSE
TRUENULLNULLTRUE
TRUEFALSEFALSETRUE
TRUETRUETRUETRUE
a OR ba AND bba
NULLNULL
TRUEFALSE
FALSETRUE
NOT aa
And, Or, Not
Erik SacreBases de Datos
Tabla para ejemploCREATE TABLE and_or( a char(1), b char(1), c char(1))
a b c-------------"1";"2";"3""4";"5";"6""7";"8";"9""4";"5";"6""1";"2";"3""4";"5";"6""4";"5";"6"
Erik SacreBases de Datos
Consultas ejemplo
select * from and_orwhere (a ='1' and b = '2') or c = '3'
"1";"2";"3""1";"2";"3"
select * from and_orwhere (a ='4' and b = '6') and c = '3'
Ninguno
a b c-------------"1";"2";"3""4";"5";"6""7";"8";"9""4";"5";"6""1";"2";"3""4";"5";"6""4";"5";"6"
Erik SacreBases de Datos
Consultas ejemplo
select * from and_orwhere a ='1' or b = '5' and c = '6'
select * from and_orwhere (a ='1' or b = '5') and c = '6'
"4";"5";"6""4";"5";"6""4";"5";"6""4";"5";"6"
"1";"2";"3""4";"5";"6""4";"5";"6""1";"2";"3""4";"5";"6""4";"5";"6"
a b c-------------"1";"2";"3""4";"5";"6""7";"8";"9""4";"5";"6""1";"2";"3""4";"5";"6""4";"5";"6"
Erik SacreBases de Datos
Consultas ejemplo
select * from and_orwhere (a not like '1' or b like '5') and c like '6'
a b c-------------"1";"2";"3""4";"5";"6""7";"8";"9""4";"5";"6""1";"2";"3""4";"5";"6""4";"5";"6"
"4";"5";"6""4";"5";"6""4";"5";"6""4";"5";"6"