如何把多个列合成一个列,然后查询? 如一个表内有列名为: id,type,text,date 如何把 type,text,date 合成一个列 然后查询?

解决方案 »

  1.   

    select type from 表名
    union all
    select text from 表名
    union all
    select datefrom 表名
      

  2.   

    select id,type+','+text+','+cast(date as varchar) from 表名
      

  3.   

    select id,type+','+text+','+cast(date as varchar) from 表名
    查询呢?
      

  4.   

    select id,type+','+text+','+cast(date as varchar) from 表名
    查询呢?-------------------
    ???
      

  5.   

    select id,type+','+text+','+cast(date as varchar) from 表名如: like '%a%'
      

  6.   

    ??select id,type+','+text+','+cast(date as varchar) from 表名 where text like '%a%'
      

  7.   

    select id,[type]+','+[text]+','+cast([date] as varchar) from 表名 where [text] like '%a%'
      

  8.   

    我想查的是组合到一块那个数据里的东西~!如下
    select id,[type]+','+[text]+','+cast([date] as varchar) as h from 表名 where h like '%a%'
      

  9.   

    我想查的是组合到一块那个数据里的东西~!如下
    select id,[type]+','+[text]+','+cast([date] as varchar) as h from 表名 where h like '%a%'
    但是不能使用~!我想了解的是如何查询 as 生成的组合列的内容
      

  10.   

    明白了:)
    select id,[type]+','+[text]+','+cast([date] as varchar) as h from 表名 where cast([date] as varchar) like '%a%'
      

  11.   

    select id,[type]+','+[text]+','+cast([date] as varchar) as h from 表名 where h like '%a%'
    --------------------------
    where h like '%a%'不能用h作为条件
      

  12.   

    需要搜索的列名是:name,ip,info表名是: data搜索的关键字是任意的~!
      

  13.   

    select * from 
    (
    select [name]+','+[ip]+','+[info] as h from data 
    ) a
    where h like '%关键字%'
      

  14.   

    select [name]+','+[ip]+','+[info] from 
    where [name]+','+[ip]+','+[info] like '%关键字%'