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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:07:03+00:00 2026-05-23T09:07:03+00:00

I was looking up different ways to write a query, and I’m just wondering

  • 0

I was looking up different ways to write a query, and I’m just wondering which way do you all think is better way to go with the following options:

SELECT a.salary 
  FROM emp a
  JOIN emp b ON a.salary < b.salary
 WHERE b.id = 200

or

SELECT salary 
  FROM emp
 WHERE salary < (SELECT salary 
                   FROM emp 
                  WHERE id = 200)

I did some execution times with about 300 records in the table, and they come out about the same, so this is really just more about preference and accepted standards. I personally like the 2nd way better (just easier to read to me). I have a feeling the 1st is standard though. What do you all think?

  • 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-23T09:07:04+00:00Added an answer on May 23, 2026 at 9:07 am

    I don’t think there is a definite answer to this question as it’s really dependent on the context of the query itself & the RDMS.

    So in your case, you’ve done the research with 300 records. How about 3,000,000? Does it make a difference?

    Personally I like Joins over Sub-Queries if I can help it, but like I said, this is really determined on a case by case basis.

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

Sidebar

Related Questions

I have tried all kinds of different ways to query this but just can't
Looking at different options: One is to just put the static pages in the
I'm looking for a way to pass different options as a parameter to a
I am looking into different ways to implement multi tenant application - one of
I am looking to integrate with sales force, hence looking at different ways on
I'm looking for the different ways to map an enum using JPA. I especially
I have been looking around at different ways to connect to URLs and there
Where are some good resources for looking at the pros/cons of different ways of
I am looking into different ways to handle updating an ASP.NET application across many
I've been looking at different ways of creating a certain physics simulation. What I

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.