请教 关于查询某个列表中的某些字段,并且显示在查询结果上
假设:TableA
有以下属性
date
NO
memo
date NO memo
2012-01-01 1 connect from 10.101.1.1 from NO address: 192.168.1.1
2012-01-01 2 connect from 10.101.1.2 from NO address: 192.168.1.2
2012-01-01 3 connect from 10.101.1.3 from NO address: 192.168.1.3
如果我写
select from TableA where memo like '%10.101.1.1%'
那么得到的结果就是
date NO memo
2012-01-01 1 connect from 10.101.1.1 from NO address: 192.168.1.1
我想知道如果我想得到的结果是
date NO memo
2012-01-01 1 10.101.1.1
我的这个SQL该如何去写?
sql
------解决方案--------------------declare @ip varchar(20)
set @ip='10.101.1.1'
select date,NO,@ip as memo from TableA where memo like '%'+@ip+'%'