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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:15:46+00:00 2026-05-29T04:15:46+00:00

I have two tables. One table contains information about Assets, another Table about their

  • 0

I have two tables. One table contains information about Assets, another Table about their relation. How could I optimize current query and getting similar results.

SELECT a1.ID FROM Asset a1
WHERE a1.AssetId =
(SELECT r.DestinationAssetId
FROM Relation r
INNER JOIN Asset a2 ON a2.AssetId = r.SourceAssetId
WHERE a2.ID = '1112174' and r.RelationshipType = 'Video File')

Results: 13412331 (ID of Asset which is related to a2.ID = ‘1125574’)

Personally I don’t like this stupid sub query, is it any way I can avoid it and optimize this query.

Thanks!

  • 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-29T04:15:47+00:00Added an answer on May 29, 2026 at 4:15 am

    You can lose the subquery:

    SELECT dest.ID 
    FROM 
    Asset src
    JOIN Relation r ON src.AssetId = r.SourceAssetId
    JOIN Asset dest ON dest.AssetID = r.DestinationAssetID
    WHERE src.ID = '1112174' and r.RelationshipType = 'Video File'
    

    Its not much of an optimization performance wise, but it is a little neater.

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

Sidebar

Related Questions

I have two tables. One table contains comments on posts, another contains commenter information
I have two tables. One contains Potential Customer information along with their Vehicle requirements
I have two tables The First one contains information about staff who take courses
I have a one to many relationship between two tables. The many table contains
I have two tables. One contains information on hotels, added to my website by
I have two tables. One contains information on hotels, added to my website by
I have two tables, DH_MASTER and DH_ALIAS . DH_MASTER contains information about a person,
I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have two tables, one for routes and one for airports. Routes contains just
I have two fields in a table. One contains values such as BTA, BEA,

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.