By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

Problem regarding a function

priyan
P: 54
Hi all,
I am having a table, in that a column called code contains a character varying datatype and has subject code in it.....
subject code will be in the form
Expand|Select|Wrap|Line Numbers
  1. 001
  2. 001.01
  3. 001.02
  4. 02345.01
  5. 002.01
  6. 001.01.01
  7. 001.01.02
  8.  
here i want to retrieve only the rows having code with one '.' dot ie., i have to retreive rows having code as 001,002,02345.

please help me......

Thanks in advance
priyan....
Oct 2 '07 #1
Share this Question
Share on Google+
5 Replies


Expert 100+
P: 700
Hi all,
I am having a table, in that a column called code contains a character varying datatype and has subject code in it.....
subject code will be in the form
Expand|Select|Wrap|Line Numbers
  1. 001
  2. 001.01
  3. 001.02
  4. 02345.01
  5. 002.01
  6. 001.01.01
  7. 001.01.02
  8.  
here i want to retrieve only the rows having code with one '.' dot ie., i have to retreive rows having code as 001,002,02345.

please help me......

Thanks in advance
priyan....
I am not sure if I get your problem but maybe it is want you want

select * from tablename where code ~ '^[^.]*\\.[^.]*$';
See here
http://www.postgresql.org/docs/curre...-matching.html
Oct 2 '07 #2

priyan
P: 54
I am not sure if I get your problem but maybe it is want you want

select * from tablename where code ~ '^[^.]*\\.[^.]*$';
See here
http://www.postgresql.org/docs/curre...-matching.html


thank u rski for helping me but i am having another doubt can i retrieve rows from the same table where the code has two dots...ie.,
Expand|Select|Wrap|Line Numbers
  1. 001.01.01
  2. 002.01.02
  3.  
Please help me
Oct 2 '07 #3

priyan
P: 54
thank u rski for helping me but i am having another doubt can i retrieve rows from the same table where the code has two dots...ie.,
Expand|Select|Wrap|Line Numbers
  1. 001.01.01
  2. 002.01.02
  3.  
Please help me
Thank u rski i got the answer thank u verymuch....but if u explain me why we are using such an expression it would be very useful for me and i would be verymuch greatful to u.....
Thanks
priyan
Oct 2 '07 #4

Expert 100+
P: 700
thank u rski for helping me but i am having another doubt can i retrieve rows from the same table where the code has two dots...ie.,
Expand|Select|Wrap|Line Numbers
  1. 001.01.01
  2. 002.01.02
  3.  
Please help me
Simple

select * from tablename where code ~ '^[^.]*\\.[^.]*\\.[^.]*$';
And read what is written on the site
http://www.postgresql.org/docs/curre...-matching.html
Oct 2 '07 #5

priyan
P: 54
Hi rski,
Thank u very much for helping me
Priyan
Oct 9 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.