mysql数据库查询例子

SELECT hos_code,hos_name,hos_agent,create_time FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2019-01-22 00:00:00’ AND ‘2019-01-22 23:59:59’ AND hos_code=;

select hos_code,hos_name,hos_agent,create_time from qrcode a,qrcode_visit_history b where a.id=qrcode_id
visit_time between XXX and XXX and hos_name=”xxx” and hos_agent=”xxx”

SELECT hos_code,hos_name,hos_agent,visit_time,visit_mac FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2019-01-22 00:00:00’ AND ‘2019-01-22 23:59:59′ AND hos_code=’HY00201’;

SELECT hos_code,hos_name,hos_agent,visit_time,visit_mac FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2018-01-22 00:00:00’ AND ‘2019-01-22 23:59:59’ AND hos_code in (‘HY00201′,’HY00000’) group by visit_mac;

SELECT hos_code ,count(distinct visit_mac) FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2018-01-22 00:00:00’ AND ‘2019-01-22 23:59:59’ AND hos_code in (‘HY00201′,’HY00000’) group by hos_code;

mysql -u root -h 127.0.0.1 -p 密码
USE helian_info;

SELECT hos_code ,count(distinct visit_mac) FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2019-02-22 00:00:00’ AND ‘2019-02-22 23:59:59’ AND hos_code in (‘HY02289’) group by hos_code;

SELECT hos_code ,count(distinct visit_time) FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2019-02-21 00:00:00’ AND ‘2019-02-21 23:59:59’ AND hos_code in (‘HY01942’) group by hos_code;

去重
SELECT hos_code,hos_name,hos_agent,visit_time,visit_mac FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2019-02-21 00:00:00’ AND ‘2019-12-31 23:59:59’ AND hos_code in (‘HY08757’) group by visit_mac;

不去重
SELECT hos_code,hos_name,hos_agent,visit_time,visit_mac FROM qrcode a,qrcode_visit_history b WHERE a.id=qrcode_id AND visit_time BETWEEN ‘2019-02-22 00:00:00’ AND ‘2019-12-31 23:59:59’ AND hos_code in (‘HY08757’) group by visit_time;