我有这些表:
Works
____________________________________________________________________
| |
|id user_id cat_id branch_id country budget explanation |
|___________________________________________________________________|
Categories
____________________________________________________________________
| |
|id category |
|___________________________________________________________________|
Categories_Branch
____________________________________________________________________
| |
|id cat_id branch |
|___________________________________________________________________|
I want them displayed like this:
____________________________________________________________________
| |
|id country budget explanation category branch |
|___________________________________________________________________|
我不能让它工作,当前的 sql 是:
SELECT works.id, works.country, works.budget, works.explanation, categories.category, categories_branch.branch
FROM works, categories, categories_branch
WHERE works.user_id = ".$_SESSION['customer_id']."
AND works.cat_id = categories.id
AND categories_branch.cat_id = categories.id
GROUP BY works.id
这会使分支组错误,显示错误的组。
有谁知道如何解决这个问题?非常感谢所有帮助。
编辑
这是一张显示我希望它如何排序的图像,问题是显示了错误的分支。