title regexp $key or body regexp $key or text regexp $key
如何获知是哪个或哪几个字段搜索到的结果

解决方案 »

  1.   

    select  title regexp $key,body regexp $key ,text regexp $key
    from xxx
    where title regexp $key or body regexp $key or text regexp $key
      

  2.   

    select 1,*
    from xxx
    where  title regexp $key 
    uinon all
    select 2,*
    from xxx
    where  body regexp $key 
    union all
    select 3,*
    from xxx
    where  text regexp $key
      

  3.   

    select 'title',*
    from xxx
    where title regexp $key  
    uinon all
    select 'body',*
    from xxx
    where body regexp $key  
    union all
    select 'text',*
    from xxx
    where text regexp $key