Very often than not we need to fetch records on some very common scenarios. Like ensuring the data is alpha or alphanumeric, whether there is any special characters or not.
I use these two queries usually. They come in handy whenever I need to get the job done.
Are column values alphanumeric?
SELECT *
FROM table_name
WHERE LOWER(column_name) = UPPER(column_name)
Are there any special characters?
SELECT *
FROM table_name
WHERE LENGTH(REPLACE(TRANSLATE(column_name,'asdfghjklqwertyuiopzxcvbnm1234567890ASDFGHJKLQWERTYUIOPZXCVBNM',' '),' ',''))>0
Just re-visiting SQL…
No comments:
Post a Comment