╔═════════════╦════════════╗
║ posts ║ categories ║
╠═════════════╬════════════╣
║ id ║ id ║
║ title ║ name ║
║ slug ║ slug ║
║ content ║ ║
║ category_id ║ ║
╚═════════════╩════════════╝
鉴于某个类别的slug
,我想选择该类别中的所有帖子。这些帖子与category_id
- >相关联id
类别。
SELECT `posts.title`
FROM `categories`
INNER JOIN `posts`
ON `posts`.`division` = "1"
WHERE `category_slug` = "$category_slug"
虽然给了我一个Unknown column 'posts.title' in 'field list'
。如何根据类别的slug选择所有帖子?
答案 0 :(得分:1)
看起来你想要
SELECT `posts`.`title`
而不是
SELECT `posts.title`
答案 1 :(得分:1)
应该是
SELECT `posts`.`title`