On 2015/11/25 1:44 AM, Igor Tandetnik wrote: > On 11/24/2015 6:07 PM, Richard Hipp wrote: >> On 11/24/15, James Hartley <jjhartley at gmail.com> wrote: >>> I would like to add a check constraint which determines if a string >>> contains all digits, ie. >>> >>> sqlite> select zip_code from zip_codes where regexp(zip_code, >>> '^[[:digit:]]+$'); >>> >>> However, this generates the error: >>> >>> Error: no such function: regexp >> >> Maybe this instead: >> >> SELECT * FROM zip_codes WHERE zip_code NOT GLOB '[^0-9]'; > > Another variation: WHERE ltrim(zip_code, '0123456789')=''
Or perhaps if a zip code must be present: WHERE zip_code <> '' AND ltrim(zip_code, '0123456789')=''