SQL条件的
我有一个sql:SQL条件的,sql,Sql,我有一个sql: Select t1.field01, t1.field02, t2.name02, t2.surname02, from lib01/FirstFile as t1, lib02/SecondFile (lib02/ThirdFile) as t2 where t1.field01 = t2.field02 (or t3.filed02) 我需要有一个条件,如果t1.field02等于AX,我必须读取第
Select
t1.field01,
t1.field02,
t2.name02,
t2.surname02,
from
lib01/FirstFile as t1,
lib02/SecondFile (lib02/ThirdFile) as t2
where
t1.field01 = t2.field02 (or t3.filed02)
我需要有一个条件,如果t1.field02等于AX,我必须读取第二个文件lib02/SecondFile,如果t1.field02等于BX,我必须读取第三个文件lib02/ThirdFile
Select
CASE
WHEN ((Select t1.field02 from lib01/FirstFile as t1 ) = AX)
THEN Select t2.name02, t2.surname02
from lib02/SecondFile (lib02/ThirdFile) as t2
CASE
WHEN ((Select t1.field02 from lib01/FirstFile as t1 ) = BX)
THEN Select t3.name02, t3.surname02
from (lib02/ThirdFile) as t3
END
如果检索不是您想要的,但这是逻辑,请更改每个THEN子句之后的代码
并尽量避免使用join的旧语法您使用的是哪种DBMS?您应该真正停止在where子句中使用那些古老的、过时的、脆弱的隐式连接,而是使用显式连接运算符