里面相应的数据有很多:比如/home/,/home/corner_one/,/home/js,/home/corner_one/......
现在我想查询/home/和/home/corner的结果。
INSERT INTO mytable
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL] like ‘/home/’and '%/home/c%'
但是显示结果不对。
请问应该如何写呢?
谢谢啦!
6 个解决方案
#1
INSERT INTO mytable
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL] ='/home/' or '/home/corner'
#2
INSERT INTO mytable select Address,Time,[Referrer URL] from test2.dbo.['status 200$'] where [Referrer URL]='/home/'
or [Referrer URL] like '/home/c%'
#3
INSERT INTO mytable
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL] ='/home/'or '/home/c%'
这是我写的代码。
错误:
訊息 4145,層級 15,狀態 1,行 3
在有預期條件的內容中指定的非布林類型運算式,接近 '/home/c%'。
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL] ='/home/'or '/home/c%'
这是我写的代码。
错误:
訊息 4145,層級 15,狀態 1,行 3
在有預期條件的內容中指定的非布林類型運算式,接近 '/home/c%'。
#4
or连接两个条件。
INSERT INTO mytable
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL]='/home/'or [Referrer URL]='/home/corner'
#5
想楼主这种数据,我认为,使用正则表达式或者全文检索,可能效率会更高。
#6
; with cte
as
(
select Address,Time,[Referrer URL]
from test2.dbo.['status 200$']
where charindex(['/home/',Referrer URL]>0 or charindex('/home/corner',Referrer URL)>0
)a
insert into mytable select * from cte
#1
INSERT INTO mytable
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL] ='/home/' or '/home/corner'
#2
INSERT INTO mytable select Address,Time,[Referrer URL] from test2.dbo.['status 200$'] where [Referrer URL]='/home/'
or [Referrer URL] like '/home/c%'
#3
INSERT INTO mytable
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL] ='/home/'or '/home/c%'
这是我写的代码。
错误:
訊息 4145,層級 15,狀態 1,行 3
在有預期條件的內容中指定的非布林類型運算式,接近 '/home/c%'。
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL] ='/home/'or '/home/c%'
这是我写的代码。
错误:
訊息 4145,層級 15,狀態 1,行 3
在有預期條件的內容中指定的非布林類型運算式,接近 '/home/c%'。
#4
or连接两个条件。
INSERT INTO mytable
select Address,Time,[Referrer URL] from test2.dbo.['status 200$']
where [Referrer URL]='/home/'or [Referrer URL]='/home/corner'
#5
想楼主这种数据,我认为,使用正则表达式或者全文检索,可能效率会更高。
#6
; with cte
as
(
select Address,Time,[Referrer URL]
from test2.dbo.['status 200$']
where charindex(['/home/',Referrer URL]>0 or charindex('/home/corner',Referrer URL)>0
)a
insert into mytable select * from cte