inner join on后面如何实现多条件查询?
from [mandala].[dbo].[PACS_His_Report] a
inner join [mandala].[dbo].[EmrRecipe] b on a.visit_ord_no in ('b.HIS_OUTERID','b.HIS_INNERID','b.AdviceId')ERID','b.AdviceId')
on后面需要加上多个条件! A表中a.visit_ord_no的 值在B表中三个字段都可能出现!
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
下面给出了我运行的一个结果
使用and连接 inner join on and ...and ...就可以了
select * from Table1 t1
inner join Table2 t2 on t1.xx=t2.xx and t2.bb = xxx and t2.cc = xxx
或者最后在where加条件
select * from table a inner join table b where 需要a表的就是a.,需要b表就是b.
join on后面可以用or条件
INNER JOIN 连接两个数据表的用法:
SELECT * FROM 表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号
INNER JOIN 连接三个数据表的用法:
SELECT * FROM (表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号
INNER JOIN 连接四个数据表的用法:
SELECT * FROM ((表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号) INNER JOIN 表4 ON Member.字段号=表4.字段号
使用and连接 inner join on and ...and ...就可以了
select * from Table1 t1
inner join Table2 t2 on t1.xx=t2.xx and t2.bb = xxx and t2.cc = xxx
或者最后在where加条件
INNER JOIN 连接两个数据表的用法:
SELECT * FROM 表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号
INNER JOIN 连接三个数据表的用法:
SELECT * FROM (表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号
INNER JOIN 连接四个数据表的用法:
SELECT * FROM ((表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号) INNER JOIN 表4 ON Member.字段号=表4.字段号
查询条件用or应该就能够实现吧
我用过where 可以用
或者 直接在where 后面加条件 用 and 或者 or 连接多条件
where b.zd1 like '%a.visit_ord_no%' or b.zd2 like '%a.visit_ord_no%' or zd3 like '%a.visit_ord_no%'