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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:46:42+00:00 2026-06-14T20:46:42+00:00

I have two tables, the first one looks like this: [Comparisons] Id (int) Car_Id1

  • 0

I have two tables, the first one looks like this:

[Comparisons]

  • Id (int)
  • Car_Id1 (int)
  • Car_Id2 (int)
  • Slug (string)
  • TimeStamp

The second one:

[VehicleSpecs]

  • Id (int)
  • Year (int)
  • Make (string)
  • Model (string)

I have this query

SELECT TOP 100 * 
FROM [Comparsions] 
WHERE 
ORDER BY [TimeStamp]

It returns the newest 100 records, but I need to replace the Car_Id1 and Car_Id2 with information from the second table like this: Car_Id1 -> [Year + Make + 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-06-14T20:46:43+00:00Added an answer on June 14, 2026 at 8:46 pm

    So what you’ll need is two INNER JOINs against the VehicleSpecs table, one for each Car_Id1 and Car_Id2. I’ve aliased them as car1, car2.

    SELECT TOP 100
      c.Id,
      c.Slug,
      c.TimeStamp,
      /* Select the relevant columns from *both* of the joined tables */
      /* And give each column an alias to differentiate it from the other */
      car1.Year AS car1Year,
      car1.Make AS car1Make,
      car1.Model AS car1Model,
      car2.Year AS car2Year,
      car2.Make AS car2Make,
      car2.Model AS car2Model
    FROM 
      Comparisons c
      /* Join first against VehicleSpecs for Car_Id1 */
      INNER JOIN VehicleSpecs car1 ON c.Car_Id1 = car1.Id
      /* Then once more for Car_Id2 */
      INNER JOIN VehicleSpecs car2 ON c.Car_Id2 = car2.Id
    ORDER BY c.TimeStamp
    

    You said you wanted the newest, so I assume you actually mean to use descending order on the timestamps:

    ORDER BY c.TimeStamp DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is for an upcoming project. I have two tables - first one keeps
i have two data tables with the same structure the first one has one
I have two tables in my database, Building and Town. They look like this:
I have two table views, when user clicks one cell of the first, second
I have a tree table with two columns on a page. The first one
I have a table inside a form. It has two columns, the first one
In my dbsql file, I have two CREATE TABLES the first works and the
I have two tables. The first table has a column with a lot of
I have two tables, the first has a primary key that is an identity,
I have two tables, the structure of the first partially recapitulates, iterates the structure

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.