SQL Pattern Matching
Could anyone tell me how you pattern match a number in SQL. For example to pattern match the letters 'AR' followed by a number: SELECT * FROM db WHERE field LIKE 'AR?'
Thanks
Could anyone tell me how you pattern match a number in SQL. For example to pattern match the letters 'AR' followed by a number: SELECT * FROM db WHERE field LIKE 'AR?'
Thanks
Maverick posted this at 18:45 — 27th July 2000.
They have: 334 posts
Joined: Dec 1999
It works the same way with numbers as it does with letters, so:
SELECT * FROM db WHERE field LIKE "AR17";
will return any field where the value is AR17
SELECT * FROM db WHERE field LIKE "%AR17%";
will return any field where AR17 is anywhere in the field
or simply for numbers:
SELECT * FROM db WHERE field LIKE "17";
or
SELECT * FROM db WHERE field LIKE "%17%";
returns where 17 is anyplace in the field
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.