this is my sample query
$sql = mysql_query("SELECT * FROM dataweb WHERE web LIKE 'google%'ORDER BY ASC LIMIT 8");
the above query is to find similar domains. but I want to remove all aka google results..开发者_高级运维.which means the result return like google.com,google.br,google.de etc.
I want only restdomains which start from google..
To do this, make it NOT LIKE instead
You want domains that begin with google
but not google.
? You can use REGEXP
for this.
SELECT web
FROM (SELECT 'google.com' AS web UNION ALL
SELECT 'google.co.uk' UNION ALL
SELECT 'google.br' UNION ALL
SELECT 'google.de' UNION ALL
SELECT 'googleplex.com' UNION ALL
SELECT 'google-watch.org' UNION ALL
SELECT 'ooglegoogle.com') dataweb
WHERE web REGEXP '^google[^.].'
ORDER BY web ASC
LIMIT 8
Returns
web
----------------
google-watch.org
googleplex.com
精彩评论