php - Select grouped table from 3 tables -
i have 3 tables in mysql.
excel - table store site-name, , side-id analys_result - table store keywords of sites, has keyword, id of category, id of site. categories - contain name , id of category
here screenshot's of tables, , need retrieve:
excel table
analys_result table
result
using sql, best can is:
select e.id, e.url, c.categoryname, a.keywords, count=sum(a.count) excel e, categories c, analys_results e.id = a.websiteid , a.categoryid = c.id grouping e.id, e.url, c.categoryname, a.keywords order e.id, e.url, c.categoryname, a.keywords this right data, grouping fields (id, url, categoryname) show on every row in result set (not 1 time per group), , making query work way using complicated sql not recommended. allow database give data, , allow ui or reporting tool using determine how want display results.
php mysql sql join
No comments:
Post a Comment