MS SQL pattern for like

sql, sql-server

Solution

Perhaps like this:

WHERE Field LIKE '%555' AND Field NOT LIKE '%[^0]%555'

Try this live on SQL Fiddle.

Problem

How can i search in sql by this rules: - field should begins from no or one and more '0' - field should end some number, for example 555 In other words pattern should match next records: ``` '555' '0555' '00555' etc ``` Can sql do this in one select query (without string splitting or something else)? Thank you.

Original source