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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:19:48+00:00 2026-06-19T04:19:48+00:00

I know this can be confusing, but please bear with me on this one.

  • 0

I know this can be confusing, but please bear with me on this one.

I have two SELECT queries with a minor difference which returns pretty much the same result set.

SELECT products_id,options_values_id
    FROM products_attributes pa
    LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
    WHERE products_id ='574' and pa.options_id!=6
    and pa.options_id!=3
    AND products_options_type = 6
    GROUP BY products_id,options_values_id
    ORDER BY products_id,products_options_sort_order,options_id

The second query varies at products_options_type

SELECT products_id,options_values_id
    FROM products_attributes pa
    LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
    WHERE products_id ='574' and pa.options_id!=6
    and pa.options_id!=3
    AND products_options_type = 2
    GROUP BY products_id,options_values_id
    ORDER BY products_id,products_options_sort_order,options_id

And the results returned by them are

574|193
574|204

AND

574|25
574|3

I want the output as

574|193|25
574|204|3

What I tried is:

SELECT pa.products_id,pa.options_values_id,ord.options_values_id
        FROM products_attributes pa
        LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )


        LEFT JOIN(SELECT products_id,options_values_id
        FROM products_attributes pa
        LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
        WHERE products_id ='574' and pa.options_id!=6
        and pa.options_id!=3
        AND products_options_type = 2
        GROUP BY products_id,options_values_id
        ORDER BY products_id,products_options_sort_order,options_id)ord ON pa.products_id=ord.products_id


        WHERE paproducts_id ='574' and pa.options_id!=6
        and pa.options_id!=3
        AND products_options_type = 2
        GROUP BY pa.products_id,pa.options_values_id
        ORDER BY pa.products_id,products_options_sort_order,options_id

However this returns

574|193|25
574|204|25

I am not too good with joins, so any idea if and how this can be done?

  • 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-19T04:19:49+00:00Added an answer on June 19, 2026 at 4:19 am

    Try this

    SELECT a.products_id,a.options_values_id, b.options_values_id
    FROM (SELECT @rownum:=@rownum+1 'rw', products_id, options_values_id
    FROM (SELECT @rownum:=0) r, products_attributes pa
    LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
    WHERE products_id ='574' and pa.options_id!=6
    and pa.options_id!=3
    AND products_options_type = 6
    GROUP BY products_id,options_values_id
    ORDER BY products_id,products_options_sort_order,options_id) a,
    (SELECT @rownum:=@rownum+1 'rw', products_id,options_values_id
    FROM (SELECT @rownum:=0) r, products_attributes pa
    LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
    WHERE products_id ='574' and pa.options_id!=6
    and pa.options_id!=3
    AND products_options_type = 2
    GROUP BY products_id,options_values_id
    ORDER BY products_id,products_options_sort_order,options_id) b
    WHERE a.products_id=b.products_id and a.rw=b.rw;
    

    Hope this helps.

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

Sidebar

Related Questions

I know this question can be answered by searching in google. But I have
I know this can seem a weird question but for me it would be
I know this can be done and i have seen it done using some
I know this is possible in Perl, but I was wondering if this can
I know this is probably something simple but I can't seem to find anything
I know this is an easy question but I can't figure it out or
I know this isn't so complicated but I can't remember how to do. I
the title is confusing sorry, if you can think of a better one, please
I’m trying to implement a simple fixed headers table. I know this can in
I would like to split a line into words. I know this can be

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.