Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7925959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:31:36+00:00 2026-06-03T18:31:36+00:00

Im having difficulties creating a query. I have googled a lot but did not

  • 0

Im having difficulties creating a query. I have googled a lot but did not find a fitting solution.
I have a table called ‘blog'(parent) and a table called ‘entry'(child):

blog

  • id
  • subject
  • owner

entry

  • id
  • blog_id
  • published (1 = published, 0 = unpublished)
  • date_created (timestamp, when created and when published)

A blog has multiple entries. Only published entries are visible to other users.

I want to create a query, which fetches the 10 latest modified blogs. For this, i would probably need a ‘foreach’ equivalent in SQL to search ALL blogs, and order them by the latest PUBLISHED entry (entry.date_modified) but only IF entry.published = 1

My SQL knowledge is not on a level which allows me to create such a query.
Additional info: using PHP (codeigniter) with MySQL

I tried this, knowing that it would never work, but it may help you as a reference for what i am trying to accomplish

SELECT blog.id
FROM blog
JOIN entry ON entry.blog_id = blog.id
WHERE entry.published = 1
ORDER by entry.date_created desc
LIMIT 0, 10 

i want my end result to be the 10 blog.id’s of which their child entry was published most recenlty. Can someone please help? All help is greatly appreciated.

If this is impossible to achieve in 1 query, perhaps with PHP i can make a foreach statement performing individual queries?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T18:31:38+00:00Added an answer on June 3, 2026 at 6:31 pm

    I believe this would work:

    SELECT blog_id
    FROM entry
    WHERE published = 1
    GROUP BY blog_id
    ORDER BY MAX(date_created) DESC
    LIMIT 0, 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having difficulties how to construct my question, but if I have to
I'm having difficulties creating a query to pull a certain result set from a
I'm having some difficulties creating a sum from values I have in a collection.
I'm having difficulties believing this question hasn't been asked before, but I couldn't find
I'm having difficulties with creating dynamic table of SDL_Surface. Take a look at that
I have been having difficulties with a piece of script I am creating, and
I'm having some difficulties creating a javascript appointment style calendar. While it does render,
I am having difficulties getting a span tag to work properly inside a table.
I'm having difficulties getting XslCompiledTransform.Load method to take a server path. I googled around
i am having difficulties creating my own Zend_Auth_Adapter. i am using Doctrine 2 with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.