this is my first question to S.O. so plz forgive the noobiness. Im also not that crash hot with SQL so I appreciate any advice on this. 

I have on table *wp\_6\_posts* which has column named *post\_content* and in that column on various rows is a text string with format:

```
http://www.domain.com/52
http://www.domain.com/182
http://www.domain.com/122

```

In another table *wp\_6\_pmlca\_links* there are rows with ID numbers that match the numbers at the end of the URl above. Also in that table is the column *afflink* which contains the URL I need (it is the only content in that field).

What I need to do is replace the entire first URL in *post\_content* with the URL from the corresponding *afflink* row.

Any/all advice is greatly appreciated.

EDIT:

For example, currently the *post\_content* column contains the text of the post for that row. It can be several thousand characters long, but within it will be either 1, or a number of URLS with the synatx above, usually in a href tag:

```
Text here to <a href="http://www.domain.com/23">Text for link</a>

```

The link that corresponds to the number in the URL is stored in a separate table as mentioned above. The row structure for that is:

```
ID | slug | URL |
----------------
23 |  23  | http://www.externaldomain.com/link |

```

What I need to do is identify the first URL, query to find the corresponding URL and the replace the first URL with the second. 

I have no idea what SQL syntax to use to construct the query Im sorry :(