Resolved: how to convert columns from char to int types
Hi - I notice that the departments column dept_no is a char type, so the range of 'd003' to 'd006' cannot be calculated since they are string values. Is there a way to change the column to a int type? or would pattern matching be more appropriate here? e.g.:
SELECT dept_name FROM departments WHERE dept_no IN ('d003', 'd004', 'd005', 'd006');
SQL doesn't allow any letters inside an INT data type. If you want the
dept_no field to be "like" an integer, you can use the combination of wildcards and the REGEXP_LIKE for pattern matching, like so:
SELECT * FROM departments WHERE REGEXP_LIKE(dept_no, '[3-6]');
Hi Larysha and Carl!
Thanks for reaching out.
Thanks for sharing this piece of information with the Community!
Carl explained it very well. SQL doesn't allow any letters inside an INT data type. So, you can use it either as CHAR or with some values of INT type.
Hope this helps.