Forum Moderators: open
im cleaning up a database with links and because there are so many wrong ones i need to speed up my deleting process.
current im using like:
SELECT * FROM my_links WHERE url LIKE '%bla.com%'
but there are more urls to check....
like whatever.com , bla.com, etc....
all nlinks that contain private pages that i want out..
i tried :
SELECT * FROM my_links WHERE url LIKE '%bla.com%' AND '%bla2.com%' AND '%bla3.com%' AND '%bla4.com%' AND '%bla5.com%'
the list goes on..
i also used OR instead of AND..
a real sample of what i have is this:
SELECT * FROM my_links WHERE url LIKE '%chello%'
SELECT * FROM my_links WHERE url LIKE '%tiscali%'
SELECT * FROM my_links WHERE url LIKE '%lycos%'
SELECT * FROM my_links WHERE url LIKE '%versatel%'
SELECT * FROM my_links WHERE url LIKE '%web-log%'
meaning that i want to delete all urls that contain the above..
but how do i do it all together..?
i also used OR instead of AND..
Or should have worked, did it not (with the changes J.H. noted?)
The only way I know to do this is script it, in the language of your choice. PHP example,
var $list = Array ('url1','url2','url3'); // etc
// You could put these in a text file or
// database field and read them in to
// populate the array
var $where='';
foreach ($list as $url) {
if ($where != '') { $where .= ' or'; }
$where .= " like '%$url%'";
}
if ($where != '') {
$select = "delete from table where $where";
// execute
}
echo your output before coding in the execute, just in case.