我有这样的架构,我想知道是否有可能在新闻列表中拥有WHERE
和ORDER BY
盯着列。
例如 category.id = x 和 cartable.status = 3 和 user.id = 4 ...
news
-------------------------------------------------------
id* title
category
-------------------------------------------------------
id* title
cartable
-------------------------------------------------------
id user_id status*
news_category
-------------------------------------------------------
news_id category_id
news_cartable
-------------------------------------------------------
news_id cartable_id
user
-------------------------------------------------------
id* name
抱歉,更新了。问题是这样的:每个新闻都有很多类别也有很多cartable ..每个cartable 都有用户。那么我如何按该字段排序或条件
select * from news_category
left join news on (news_category.news_id = news.id)
left join category on (news_category.category_id = category.id)
--- cartable and user ???