Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

select with regexp

 
   Database Help (Home) -> mySQL RSS
Next:  Oracle 10G RELEASE 1 ON HP UNIX  
Author Message
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 1) Posted: Fri Feb 18, 2005 4:40 am
Post subject: select with regexp
Archived from groups: mailing>database>mysql (more info?)

i have a column "path" with values eg.

+---------------+
| path |
+---------------+
|/path/path/path|
+---------------+
|/path/path |
+---------------+
|/path |
+---------------+

i want to select the row where there are X number of "/". I THINK i am
suppose to use regexp. anybody knows the syntax?

select path from tablename WHERE path REGEXP _____________

 >> Stay informed about: select with regexp 
Back to top
Login to vote
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 2) Posted: Fri Feb 18, 2005 4:40 am
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > i have a column "path" with values eg.
 >
 > +---------------+
 > | path |
 > +---------------+
 > |/path/path/path|
 > +---------------+
 > |/path/path |
 > +---------------+
 > |/path |
 > +---------------+
 >
 > i want to select the row where there are X number of "/". I THINK i am
 > suppose to use regexp. anybody knows the syntax?
 >
 > select path from tablename WHERE path REGEXP _____________

nmind. i got it.

'^(/[\\d\\w]){X}' where X is a variable

 >> Stay informed about: select with regexp 
Back to top
Login to vote
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 3) Posted: Fri Feb 18, 2005 4:40 am
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:

 > select path from tablename WHERE path REGEXP _____________

nmind. i got it.

'^(/[\\d\\w]*?){1}'
 >> Stay informed about: select with regexp 
Back to top
Login to vote
user

External


Since: Feb 18, 2005
Posts: 8



(Msg. 4) Posted: Fri Feb 18, 2005 4:40 am
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > - wrote:
 >
  >> select path from tablename WHERE path REGEXP _____________
 >
 >
 > nmind. i got it.
 >
 > '^(/[\\d\\w]*?){1}'

oops. doesn't work as expected.

this is the correct one i suppose.
'^(/[\\d\\w]*?){X}$' where X is the expected no. of '/'.

but how do i put a variable in there? is it
'^(/[\\d\\w]*?){' && variable && '}$'
 >> Stay informed about: select with regexp 
Back to top
Login to vote
Bill Karwin1

External


Since: Jun 17, 2004
Posts: 42



(Msg. 5) Posted: Fri Feb 18, 2005 2:33 pm
Post subject: Re: select with regexp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > but how do i put a variable in there? is it
 > '^(/[\\d\\w]*?){' && variable && '}$'

This should work:

WHERE path REGEXP CONCAT('^(/[\\d\\w]*?){', variable, '}$')

Regards,
Bill K.
 >> Stay informed about: select with regexp 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Select more than just * - Is it possible to run a query like this: SELECT *, DATEDIFF(CURDATE(), `updated`) AS `daysSinceUpdate` FROM `Admin` Or should I let PHP calculate the days since update?

Random select - Hi, When I do a select with a limit I get always the same records. Usually this is the desidered effect. But now I want to do a random select. So every time I do a select I should get a different set of results. What is the best way to achieve this..

Select Query Help - I'm struggling - with my limited knowledge of SQL - to write a query that does what I want it to, and I was hoping that someone here may be able to help out. I have a table with two columns, user1 and user2, which store user ID's. For example: ..

Count lines in select - I have a table t1: id int unique added timestamp and second table t2: eid int id int unique t2.id are IDs from t1. t2.eid with the same value can be found in t2 more than for one entry but they will all have different IDs. I want to: ..

Restoring select databases/tables from an --all-databases .. - I use the --all-databases switch to backup my entire database. Sometimes there's a need to restore individual databases or tables form the backup file. What command should I use for this? Thanks, Raffi
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]