mysql -uxxx -pyyy

use lottery;

select count(id) from mop_bet_order_history where created_at < '2015-11-01';

    统计mop_order_history表中2015-11-01之前的数据条数

    count(id)统计条数


select * from mop_bet_order_history where created_at < '2015-11-01' into outfile '/data/tmp-2015-11.csv' fields terminated by ',';

    在mop_bet_order_history表中,查找2015-11-01之前的数据,并导出到/data/tmp-2015-11.csv文件中,并将数据以 ','分隔开。


select * from mop_bet_order_history where created_at < '2015-11-01' AND created_at >'2015-10-01' into outfile '/data/tmp-201510-11.csv' fields terminated by ',';

    在mop_bet_order_history表中,将2015-10-01之后,2015-11-01之前的表导出到/data/tmp-201510-11.csv文件,并以','分隔开数据。

    where使用and/or指定多个查询条件,比如select * from student where sex='男' and age-20;

    select field1,field2.. from table1,table2.. where condition1 [and/or] condition2..

        ','分隔指定一个或者多个查询的表;

        and/or同时指定多个查询条件;