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 7689587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:11:57+00:00 2026-05-31T20:11:57+00:00

I have a table articles that has a column company which has list of

  • 0

I have a table “articles” that has a column “company” which has list of companies or an article type – crappy I know, but it’s not my DB. 🙂 Let’s say there are n articles for each type. I need to select the first article (based on year, or any other criteria) that is of the type. Something like this:

select * from details where (company = 'aaa' or company = 'bbb' or ...)

I know what the types are, so they can be hardcoded. I need to limit only the first article for each type. Thanks!

EDIT

given the sample data:

id  company  copy   issue
------------------------
1   apple    'abc'  NULL
2   bmw      'abc'  NULL
3   ibm      'abc'  NULL
4   news     'abc'  2
5   news     'abc'  3
6   seagate  'abc'  NULL
7   events   'abc'  1
8   features 'abc'  5
9   samsung  'abc'  NULL

I need rows 4, 7, 8.

EDIT2

Sorry if I wasn’t clear. Essentially the table contains two different types of data. One is company info, and one is article info. Basically I need to do this:

select * from articles where company = "news" order by issue limit 1;
select * from articles where company = "events" order by issue limit 1;
select * from articles where company = "features" order by issue limit 1;

but with a single query.

  • 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-31T20:11:58+00:00Added an answer on May 31, 2026 at 8:11 pm

    Something like this perhaps

    select * from details d
    where company in ('news', 'events', 'features')
    and not exists (
        select 1 from details d_
        where d_.company = d.company
        and d_.id < d.id -- provide your sortable criteria here
    )
    

    Example here – http://sqlfiddle.com/#!2/bb8f2/6

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple cakephp app with table articles that has a cat_id column
Lets say I have a table in MySQL called articles, that has a column
I have a table named tbl.Products , which has a column named articlenumber and
In my PHP application, I have a mysql table of articles which has the
I have File-Stream enabled database. I have created table with column that has the
I have a primary table for Articles that is linked by a join table
I have a table that contains articles posted by users. The structure of the
I have one table, e.g. pricerules, that have stored special prices by article for
Hello I have a table with articles and the articles have a column category.
I have a DataSet which has one table loaded with data. When i write

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.