im trying to validate a column using postgresql
where values in the column are (0000-ASZAS) four numerical values-five alphbets
SELECT invoice_number,
CASE
WHEN invoice_number = '[0-9][0-9][0-9][0-9]-[A-Z][A-Z][A-Z][A-Z][A-Z]'
THEN 'valid'
ELSE 'invalid'
END
from invoices;
also tried LIKE instead of =
sorry wrong column customer_id with alpha numeric values
invoice_number is numeric. thank you for the correction
3
Answers
I'm cleaning a data and want to return 0 rows so it doesn't crowd the results so this is what I did...
w/c gives me exactly what I want. Would this be as strong/valid for cleaning compared to using like or = ?
Try ~ or similar_to. See functions-matching
You may use the
~
POSIX regex operator: