Computing.Net > Forums > Database > SQL text search loop

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SQL text search loop

Reply to Message Icon

Name: thor42
Date: January 16, 2009 at 06:44:29 Pacific
OS: Windows XP
CPU/Ram: unknown / 512MB
Product: Unknown / UNKNOWN
Subcategory: MySQL
Comment:

Hi,

i'm using mysql 5.0.27. There is a table named contents. It has a column named body. I would like to extract all URL from column body. There might be none or several of them. The column body has the datatype text. How could that be done?



Sponsored Link
Ads by Google

Response Number 1
Name: orange
Date: January 18, 2009 at 07:34:18 Pacific
Reply:

You don't indicate if the urls you are seeking are explicit website addresses or fragments of html etc. If there are multiple urls within a given record, you will have to parse (search, edit/extract) the text string and break it into individual urls.

You can select only those records that have some text in the body column.
SELECT BODY from CONTENTS
WHERE BODY is NOT NULL.

You can select only those records that have urls (depending on the format of such urls) Will your data have the http:// or not?

SELECT BODY from CONTENTS
WHERE BODY like ("http://*")

Here the * represents any number of any char.
Check the proper character for this in MySql.

You did not indicate if multiple urls are separated by comma, space, tab etc.
So you will have to manipulate any results to separate out individual urls.
Hope this is helpful.


0

Response Number 2
Name: jon_k
Date: January 19, 2009 at 09:00:29 Pacific
Reply:

yeah, see above post but in mysql you need to use the % character rather than the asterisk.


0

Response Number 3
Name: thor42
Date: January 23, 2009 at 16:48:41 Pacific
Reply:

Thanks for the responses. The column body contains multiple "http://a.php<br />" strings. I would like to insert all of them from all rows into another table. Each of them should go into it's own row.

<-- body := "http://a.php-del- test test http://b.php-del-"

-del- would be "lt br space slash gt"

another table should be filled with:
--> row 1: "http://a.php"
--> row 2: "http://b.php"

How could they be all fetched and written?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: SQL text search loop

FTS(Full Text Search) in sql server www.computing.net/answers/dbase/ftsfull-text-search-in-sql-server/414.html

SQL2000 Job Problems www.computing.net/answers/dbase/sql2000-job-problems/225.html

Access Query to Form Question www.computing.net/answers/dbase/access-query-to-form-question/50.html