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

  • SEARCH
  • Home
  • 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 6701023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:53:03+00:00 2026-05-26T06:53:03+00:00

I am having trouble selecting first photo ( thumb_filename ) and date added (

  • 0

I am having trouble selecting first photo (thumb_filename) and date added (date_added) on every unique article. Every unique article is a gallery for itself.

I am beginner in MySQL, so hope someone could help.

CREATE TABLE IF NOT EXISTS `photographs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `article_id` int(11) NOT NULL,
  `thumb_filename` varchar(255) NOT NULL,
  `full_filename` varchar(255) NOT NULL,
  `date_added` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `article_id` (`article_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=31 ;

I know to use SELECT thumb_filename, date_added FROM photographs and than to filter this out using PHP. I don’t know how to set condition for unique article_id…

  • 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-05-26T06:53:03+00:00Added an answer on May 26, 2026 at 6:53 am

    Untested of course, but this may do the job for you. This isn’t the only way to do it, but it is a straightforward way. It pulls photograph ids for the earliest date_added of each article_id and then uses those to retrieve the filename.

    SELECT 
      thumb_filename,
      date_added
    FROM photographs
    WHERE id IN (SELECT id FROM photographs GROUP BY article_id HAVING MIN(date_added))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble efficiently selecting the information I need to display. Hopefully someone
I am having trouble selecting an item from a Javascript dropdown (i.e. the items
I am having trouble selecting a hidden form field value that is a part
I'm having trouble selecting a subset of data with doctrine. I have 3 tables
I'm having trouble finding out the proper syntax for selecting from a table all
I'm having trouble selecting the input value from this html: <li class=t-item> <div class=t-mid>
Having some trouble selecting some nodes in the rss feed for twitter's search the
I'm having bit of a trouble selecting correct values from my mysql sql server.
I'm having trouble selecting links in my html. Here's the html I have: <div
I am having major trouble selecting the most current/matching row in my database. For

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.