tags:

views:

72

answers:

2

When i use . operator in like operator query is not selecting any of the records.

here is my query. how to use " . " in LIKE .

SELECT * FROM XSP_AssetList_V  WHERE AccountID = '5d6b1eab-1697-de11-a2d1-00505617006d'  AND PrinterSerialNumber LIKE '%13.12%' 
+4  A: 

In SQL, the single character wildcard is "_" not "."

LIKE '%13_12%'
  • % match any string of zero or more characters.
  • _ match any single character.
  • [ ] match any single character within the specified range (for example, [a-f]) or set (for example, [abcdef]).
  • [^] match any single character not within the specified range (for example, [^a - f]) or set (for example, [^abcdef]).
Yada
I think the OP is not looking for a single-character wildcard. It's asking why the actual '.' character isn't matching where it should.
Aaron
A: 

what you are doing should work, maybe your AccountID is incorrect or the combination of both doesn't return anything

create table #test(ip varchar(16))
insert #test values ('13.121.238.11')
insert #test values ('13.124.254.128')
insert #test values ('127.0.0.1')

select * from #test where ip like '%13.12%' 
SQLMenace
combination of both works SELECT * FROM XSP_AssetList_V WHERE AccountID = '5d6b1eab-1697-de11-a2d1-00505617006d' AND PrinterSerialNumber LIKE '%13%' will display recordsbut this does not display recoredsSELECT * FROM XSP_AssetList_V WHERE AccountID = '5d6b1eab-1697-de11-a2d1-00505617006d' AND PrinterSerialNumber LIKE '%13.12%'
xrx215