Reputation: 7448
I'm trying to filter the results using this SQL expression:
SELECT ModelName, ModelSvmData, TrainedFeatureInfo, TrainedClassesInfo
FROM Models
WHERE NOT ModelName LIKE '_%'
(Names having underscore are to be filtered actually)
Unfortunately there are no results.
The column ModelName
does contain 2 rows main
and _main
Any hint?
Upvotes: 0
Views: 191
Reputation: 135729
The underscore character is a wildcard in the LIKE clause for a match of any single character. If you want to look for the literal underscore, you need to escape it so it is not treated as a wildcard.
...WHERE ModelName NOT LIKE '\_%' ESCAPE '\'
Upvotes: 5
Reputation: 10009
This is the correct syntax:
SELECT ModelName, ModelSvmData, TrainedFeatureInfo, TrainedClassesInfo
FROM Models
WHERE ModelName NOT LIKE '\_%'`
You need to escape _
using \
as _
itself is a wild card character.
You can see other examples here
Upvotes: 3