Home > database >  Excuse me, like the use of the multiple values
Excuse me, like the use of the multiple values

Time:02-06

Where the name of the building (in '13', 14 'house', '15', '13 # building', '14 # building', '15 # building) can inquire multiple values in the field, but if you use the Like:
Like '% 13%' and the Like '% 14%' and the Like '% 15%'
Excuse me, could Like Like In use? When be Like multiple values, what is the fast way? thank you

CodePudding user response:

 
Like '% % [15] 13 14 | |'

CodePudding user response:

 
Where building names like '% % 13 house or building name like' % % 14 buildings'

CodePudding user response:

 USE tempdb for 
GO
IF OBJECT_ID (' t ') IS NOT NULL DROP TABLE t
GO
CREATE TABLE (t
N NVARCHAR (20)
)
GO
INSERT INTO t (n) VALUES (' 13 building), (' 14 building), (' 15 'house), (' 16), (' # 13 building), (' # 14 building), (' # 15 building), (' # 16 building)
GO
SELECT * FROM t WHERE n LIKE '% 1 [3-5] %'
SELECT * FROM t WHERE n LIKE '% % 1/3 4 | | 5'
/*
N
13 building
14 building
15 house
13 # building
14 # building
15 # building
*/

CodePudding user response:

Considering the efficiency:
Select * from XXX Where building names like '13 building %' or building name like '14 building %'
Don't yesterday %, the query will be much faster,

CodePudding user response:

Use the or to go,

CodePudding user response:

Where exsts (select * from (values (' % 136% '), (' % 135% ')) L (v) where TB. The name like L.v)

CodePudding user response:

Like '% % [15] 13 14 | |'

CodePudding user response:

Regular expressions: one or more digital + 0 or 1 # + building
\ d + #? Building

CodePudding user response:

Quote: refer to the third floor of gypsy song response:


[3 4 | | '% 1 5) %'
In an array element number limit
  • Related