Like operator ( [ ] ) in SQL
1. Matching Specific Characters in Product IDs
Query - Select * From [Product_data_abu] Where ProductCode Like '[1234]%'
How it works -
[1234]%→ Matches values where the first character is 1, 2, 3, or 4.It excludes
5D67and7F90(since their first digit isn’t in[1234]).
Source DE :-
2.Matching Specific Numbers in Comma-Separated Lists
Different positions in the list are checked:
[1-4]→ Matches if the first value is1, 2, 3, or 4.[1-4],%→ Matches if the first value is followed by more values.%,[1-4],%→ Matches if1, 2, 3, or 4appears anywhere in the middle.%,[1-4]→ Matches if1, 2, 3, or 4is the last value.
💡 Why is this important?
Without checking different positions, SFMC SQL wouldn’t find values inside the comma-separated list.
3. Using [] with Letters
Query - Select * From [Customers_Abu] Where CustomerName Like '[ABC}%'
How it works -
[ABC]%→ Matches names starting with A, B, or C.It excludes
DavidandEmilysince their first letters aren’t in[ABC].
4. Using [] to Escape Special Characters
[%]tells SQL to treat%as a normal character, instead of a wildcard.Without
[ ], SQL would treat%as "match any characters", leading to incorrect results.
Comments
Post a Comment