I am stuck on one query in MySQL.
I want to get the most recent comment from the table
- the comment should be the last blog comment
- blogs should be the last 3 blogs.
- display comments and blog only if their status is enabled
entries should be like this


Table Structure for Table Blog Table
blog_id int - primary (auto increment)
blog_title -varchar
blog_desc -varchar
blog_image -varchar
blog_tags -varchar
tot_comments -int
blog_creater -varchar
blog_create_date -datetime
blog_status -enum ('Enable', 'Disable')
table structure for blog_comment table
comment_id -int (auto increment)
fk_blog_id -int
comment -varchar
comment_by -varchar
email -varchar
comment_date -datetime
comment_status -enum ('Enable', 'Disable')
The following is a query written by me, but the result that I get is incorrect.
SELECT b.blog_title,b.blog_image, bc.* FROM blog_comments bc, blog b WHERE bc.comment_status='Enable' AND b.blog_status='Enable' AND b.blog_id=bc.fk_blog_id GROUP BY bc.fk_blog_id ORDER BY bc.comment_date DESC LIMIT 0,3
Exit

php mysql
Alpesh trivedi
source share