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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:50:10+00:00 2026-06-09T00:50:10+00:00

I had a long query, I short it out by using joins instead and

  • 0

I had a long query, I short it out by using joins instead and resultant query is as below but still it has sub query. How to convert this sub query to join

SELECT 
    pav.post_id as Id, img.path as Path, attr.name as Name, pc.title as Category, pav.value_text as Valuess, post.created_on as createdOn 
FROM 
    postings post inner join post_attributes_values pav on post.post_id = pav.post_id
    left outer join images img on post.post_id = img.post_id and img.sequence='1' 
    inner join attributes attr on pav.attr_id = attr.attr_id 
    inner join categories_parent_categories pc on attr.cat_id = pc.category_id 
where 
    pav.post_id in  (select distinct post_id from post_attributes_values where value_text = 'SFX') 
  • 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-09T00:50:12+00:00Added an answer on June 9, 2026 at 12:50 am

    After reading your last comment to Matei’s answer I have come to realize that you actually want ALL the posts where one of the attributes has value of ‘SFX’. If I understood correctly, your only alternative is to add derived table and join by post_id:

    SELECT pav.post_id     AS Id,
           img.path        AS Path,
           attr.name       AS Name,
           pc.title        AS Category,
           pav.value_text  AS Valuess,
           post.created_on AS createdOn
    FROM   postings post
           INNER JOIN post_attributes_values pav
                   ON post.post_id = pav.post_id
           LEFT OUTER JOIN images img
                        ON post.post_id = img.post_id
                           AND img.sequence = '1'
           INNER JOIN attributes attr
                   ON pav.attr_id = attr.attr_id
           INNER JOIN categories_parent_categories pc
                   ON attr.cat_id = pc.category_id
           INNER JOIN
           (
                 SELECT DISTINCT post_id
                 FROM   post_attributes_values
                 WHERE  value_text = 'SFX'
           ) sfxPosts
                   ON pav.post_id = sfxPosts.post_id
    

    (Query reformatted thanks to instant sql formatter.)

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

Sidebar

Related Questions

I've been a long time browser here, but never have had a question that
Has anyone had this problem? My projects tend to have some long XML files
Sorry for the long post, but most of it is code spelling out my
I had a strange problem in one of our production databases. Long story short,
I know this might be redundant but I have had the same query running
I had a long query in access and trying to make it into multiple
One thing with which I have long had problems, within the CakePHP framework, is
In another question I had the problem to port the code: unsigned long stack[]
I am a long time C# developer and have had to look at some
It's been a long time since I've had to deal with Win32 menus. 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.