我有表1,表2,表3表1有字段 图片地址
表2有字段 地址
表3有字段 路径(设计数据库的脑袋让驴踢了....)现在我有一文件 123.jpg怎么查询在三张表里对应的字段是否存在?只要确定是否存在就可以..

解决方案 »

  1.   

    if exists(select 1 from (select 图片地址 from tab1 union all select 地址 from tab2 ...) a where ....)
      

  2.   

    123.jpg--这个东西是路劲?图片地址?或者别的什么?这个总知道吧
      

  3.   

    表1有字段 图片地址
    表2有字段 地址
    表3有字段 路径select 对应的字段from tbla where 对应的字段='123.jpg'
    union all
    select 对应的字段from tblb where 对应的字段='123.jpg'
    union all
    select 对应的字段from tbl where 对应的字段='123,jpg'有结果证明存在,没结果证明不存在
      

  4.   

    select * from 
    (select  图片地址 as url  from 表1
    union 
    select  地址 as url from 表2
    union 
    select   路径 as url from 表3
    ) v where url like'%123.jpg%'