mysql語句查詢
問題描述
DROP TABLE IF EXISTS merchants;CREATE TABLE merchants (id int(10) unsigned NOT NULL AUTO_INCREMENT,name varchar(255) DEFAULT NULL,ip char(15) DEFAULT NULL, PRIMARY KEY (id)) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
-- ------------------------------ Records of merchants-- ----------------------------INSERT INTO merchants VALUES (’1’, ’abc.com’, ’127.0.0.1’);INSERT INTO merchants VALUES (’2’, ’abc.com’, ’127.0.0.1’);INSERT INTO merchants VALUES (’3’, ’abc.com’, ’112.112.112.112’);INSERT INTO merchants VALUES (’4’, ’bbc.com’, ’127.0.0.1’);INSERT INTO merchants VALUES (’5’, ’bbc.com’, ’127.0.0.1’);
這是mysql語句,我想實現abc.com 有效ip為2bbc.com 有效ip為1這語句怎么寫,求大神指點指點!謝謝!
問題解答
回答1:SELECT `name`, COUNT(DISTINCT ip) AS ’有效IP’ FROM merchants GROUP BY `name`
相關文章:
1. docker容器呢SSH為什么連不通呢?2. docker - 如何修改運行中容器的配置3. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. docker start -a dockername 老是卡住,什么情況?5. Android TextView 或 ListView 加載過渡效果6. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?7. python - thrift 返回 TSocket read 0 bytes 求助!!!!8. python3.x - python中import theano出錯9. python - (初學者)代碼運行不起來,求指導,謝謝!10. python - django模板 include模板的數據問題
