0

I am trying to write this query:

SELECT DISTINCT createdcfgid FROM ab WHERE (createdcfgid ~ ‘^[0-9]+$’)

This results in

 syntax error at or near "[" LINE 3: WHERE (createdcfgid ~ ‘^[0-9]+$’)

Anyone there who can give me a clue about what I am doing wrong?

Thanks in advance

1 Answer 1

1

It does just look like you are using the wrong quotes, try ' rather than :

PostgreSQL 8.4 Schema Setup:

create table ab(createdcfgid text);
insert into ab(createdcfgid) values ('111');

Query:

SELECT DISTINCT createdcfgid FROM ab WHERE (createdcfgid ~ '^[0-9]+$')

Results:

| CREATEDCFGID |
----------------
|          111 |

this on SQL Fiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.