开发者

How do I minus data from query?

开发者 https://www.devze.com 2023-02-10 14:56 出处:网络
this is my sample query $sql = mysql_query(\"SELECT * FROM dataweb WHERE web LIKE \'google%\'ORDER BY ASC LIMIT 8\");

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
0

精彩评论

暂无评论...
验证码 换一张
取 消