Is there any way to build a REGEXP pattern set by using a subquery?

I have a set of rows in table "table", with the column "value" being
target for my query. That column's content is a bracket separated list
of values, like this:

[118][Word][Integer][Stuff]...
[67][Another word][Another integer][More stuff]...

Now, to get all rows which "value string" starts with "[118]", this
does the trick:

SELECT * FROM table WHERE value REGEXP '^\\[118'

And further on, to get all rows which "value string" starts with
either [21], [42] or [999], this works fine:

SELECT * FROM table WHERE value REGEXP '^\\[(21|42|999)'

But I need to be able to do this last query without having to specify
the values by hand, but with a subquery. Imagine the following query:

SELECT id FROM items WHERE parent=5

This gives me a result set of rows which "parent" columns matches 5. I
would like to use all these results in the last REGEXP query example
above, something like this:

SELECT * FROM table WHERE value REGEXP '^\\[(SELECT id FROM items
WHERE parent=5)'

Anyone got any clues?

--
Kim Christensen
[EMAIL PROTECTED]

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to