|
3 main watches
eqs_users: user information table field id (primary key) other information fields
ws_users_info: user details table field uid other information fields
ws_cn_sell: Sales information table Field uid Other information fields
Three tables, id, uid, uid are related. First, you must count the customers who have posted more than 10 sales information, and you need to paginate
This is my statement for fetching data
SELECT a.id, a.username, a.name, a.ip, b. *, (SELECT count (*) FROM ws_cn_sell sell WHERE sell.uid = b.uid) AS sell_num FROM eqs_users a LEFT JOIN ws_users_info b ON a .id = b.uid WHERE 1 = 1 HAVING sell_num> = 10 ORDER BY a.register_date DESC LIMIT 0, 20
Below is the pagination I used to count the customers who posted more than 10 sales information
SELECT COUNT (*) FROM eqs_users a LEFT JOIN ws_users_info b ON a.id = b.uid WHERE 1 = 1 HAVING sell_num> = 10
Obviously the statistics are wrong because there is no sell_num at all.
I would like to implement the above function, how do I write a statement, both to search it out and to total the pages? ? ? |
|