php - get table information using feching table in mysql stored procedure -
help....
i have 2 tables,
customers
id | registration_code | full_name 1 | a01 | abc 2 | b01 | bcd 3 | c01 | cde 4 | d01 | def
history_transaction
id | customer_id | transaction_date 1 | 1 | 2015-01-01 2 | 2 | 2015-01-01 3 | 3 | 2015-01-01 4 | 1 | 2015-01-02 5 | 3 | 2015-01-02 6 | 1 | 2015-01-03
i use php, , want customer list , transaction times between 2015-01-01 till 2015-01-03
the result should
id | registration_code | full_name | n_trans 1 | a01 | abc | 3 2 | b01 | bcd | 1 3 | c01 | cde | 2
please help. want use store procedure on mysql, , dont want loop in php.
to info use group statement:
select a.id,a.registration_code,a.full_name, count(*) n_trans customers inner join history_transaction b on a.id=b.customer_id b.transaction_date between "{start_date}" , "{end_date}" group a.id,a.registration_code,a.full_name;
you can set start_date , end_date dynamically using mysqli (a php module working mysql php).
Comments
Post a Comment