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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:42:35+00:00 2026-06-12T07:42:35+00:00

Check this fiddle for DB and tables SELECT p.* FROM Products p LEFT JOIN

  • 0

Check this fiddle for DB and tables

SELECT p.*
FROM Products p
LEFT JOIN offertran ot 
ON p.prod_id = ot.prod_id
LEFT JOIN Offers o
ON ot.offer_id =  (SELECT id FROM Offers 
                   Where dF<=3 AND dt>=3)

ORDER BY o.id DESC, 
          p.prod_id ASC
LIMIT 20

The Output is:

| PROD_ID | CATEGORY_ID | PROD_NAME |  BRAND | PRICE | STATUS |
---------------------------------------------------------------
|      p3 |          c1 |     prod3 | brand3 |  3000 | active |
|      p3 |          c1 |     prod3 | brand3 |  3000 | active |
|      p1 |          c1 |     prod1 | brand1 |  1000 | active |
|      p2 |          c2 |     prod2 | brand2 |  2000 | active |
|      p4 |          c2 |     prod4 | brand1 |  4000 | active |
|      p5 |          c1 |     prod5 | brand2 |  5000 | active |
|      p6 |          c2 |     prod6 | brand3 |  6000 | active |

But, here as you can see p3 is shown two times. I dont know why..
I had tried all the possible ways but I cant find any remedies.. 🙁

  • 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-12T07:42:36+00:00Added an answer on June 12, 2026 at 7:42 am

    The problem in

    LEFT JOIN Offers o
    ON ot.offer_id =  (SELECT id FROM Offers 
                       Where dF<=3 AND dt>=3)
    

    You join ot.offer_id with constant values (there is no meaning you select them from offers table).

    The correct way:

    SELECT p.*
    FROM Products p
    LEFT JOIN offertran ot 
    ON p.prod_id = ot.prod_id
    LEFT JOIN Offers o
    ON ot.offer_id = o.id AND o.dF<=3 AND o.dt>=3
    ORDER BY o.id DESC, 
              p.prod_id ASC
    LIMIT 20
    

    Look at this SQLFiddle

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

Sidebar

Related Questions

I have 3 tables and I want to join it. Check this fiddle: http://sqlfiddle.com/#!2/20410/2
Check this example before reading the question - http://www.sqlfiddle.com/#!2/fcf3e/8 The following data comes from
UPDATE If you try the form on this link http://jsfiddle.net/Matt_KP/BwmzQ/ the fiddle and select
I have this problem with tables from my app. When the description of a
If you check out this JS fiddle: http://jsfiddle.net/DE5Bp and try to sort the Tariff
http://jsfiddle.net/9aaNh/ Please check this Fiddle. I am having problem with spacing in between text
I have a check box like this: fiddle <input type=checkbox value=False id=abc> and in
Check out this fiddle: http://jsfiddle.net/mattball/nWWSa/ var $lis = $('ul.innerfade > li'); function fadeThemOut() {
Check out this fiddle: http://jsfiddle.net/sajYc/ The transition for the :after pseudo element works in
Please check out this fiddle: http://jsfiddle.net/dppJw/8/ I've used a pseudo-element for the body (also

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.