Welcome to WebmasterWorld Guest from 54.80.189.255

Forum Moderators: open

Message Too Old, No Replies

Using a SELECT statement with REGEXP REPLACE Placeholder

     
11:05 am on Sep 8, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 4, 2004
posts:886
votes: 1


Is this possible? How do I get the placeholder \\1 into the select statement to get the value out of the other table?


UPDATE phpbb_posts SET post_text = REGEXP_REPLACE
(
post_text,

'http://example.com/about([0-9]{1,5}).html',


CONCAT('https://example.com/forum/viewtopic.php?f=' , (SELECT `forum_id` FROM phpbb_topics WHERE `topic_id` = '\\1') , '&t=\\1')
)


This is a one off query but I have a few other similar ones to perform. I could write a script but this would make life a lot easier now and down the road for similar queries. The problematic part is this.

(SELECT `forum_id` FROM phpbb_topics WHERE `topic_id` = '\\1') 


I'm getting 0 results presumably because it's not using the placeholder value. If I change \\1 to an actual topic ID number it works fine but of course that doesn't give me the topic ID's i need.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members