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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:45:48+00:00 2026-05-25T12:45:48+00:00

I need to select a specific model from the Models table using its key

  • 0

I need to select a specific model from the Models table using its key ModelID. I also need to add a blurb of content from the Model_Content table. The Models_Content table, however, has several blurbs of content for each model. I need to select just the first blurb.

My tables look like this:

 Models // table
 ModelID // pk
 Model // varchar

 Models_Content // table
 ContentID // pk
 ModelID // fk
 Content // varchar

 SELECT M.ModelID, M.Model, C.Content
 FROM   Models M LEFT JOIN Models_Content C ON M.ModelID =  C.ModelID
 WHERE      M.ModelID = 5

How do I adjust my query to select just the very first blurb of content for a specific model?

  • 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-25T12:45:49+00:00Added an answer on May 25, 2026 at 12:45 pm
     SELECT
       M.ModelID, M.Model, C.Content
     FROM
       Models M
     LEFT JOIN
       Models_Content C
         ON C.ContentID = (SELECT MIN(ContentID) FROM Models_Content WHERE ModelID = M.ModelID)
     WHERE
       M.ModelID = 5
    

    Or

    ;WITH sorted_content AS
    (
      SELECT
        ROW_NUMBER() OVER (PARTITION BY ModelID ORDER BY ContentID) AS itemID,
        *
      FROM
        Models_Content
    )
     SELECT
       M.ModelID, M.Model, C.Content
     FROM
       Models M
     LEFT JOIN
       sorted_content C
         ON  C.ModelID = M.ModelID
         AND C.itemID  = 1
     WHERE
       M.ModelID = 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a <select>. Using JavaScript, I need to get a specific <option> from
I have need to select a number of 'master' rows from a table, also
I need to upadte, add and delete rows from the auth.models.User table, unfortunately... when
I need a select from table which does not have column that tells when
I need to select 90 columns out of 107 columns from my table. Is
I need to select a bunch of data into a temp table to then
I need to select a datetime column in a table. However, I want the
I need to select a specific grange of jquery elements based on there index
I have a process that needs to select rows from a Table (queued items)
I'm setting up a data model in django using multiple-table inheritance (MTI) like this:

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.