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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:46:56+00:00 2026-06-07T16:46:56+00:00

I’m trying to get a product search to work properly in MySQL 5.0.88. Basic

  • 0

I’m trying to get a product search to work properly in MySQL 5.0.88.

Basic setup: I have table A with products

A.id
A.ean
A.styleNo
A.price
A.seller (ID e.g. 123, 456)

And a table B with pricelists

B.name
B.ean
B.alt_price
B.seller

Sellers can define optional pricelists, which are matched to the user doing the search. My search more or less looks like this:

    SELECT A.styleNo, A.price, B.price
    FROM arts A
        LEFT JOIN pricelists B ON
                B.seller = A.seller 
            AND B.ean = A.ean 
            AND B.alt_price != 0
    WHERE...
    // pricelists
    AND ( B.name = "some_name" AND B.seller = "123" ) OR ( next applicable seller ) ...

So after the LEFT JOIN, I’m including all items from a pricelist by name and seller.

This works ok as it selects both the regular price (A) and alt_price (B) and I can check for existing alt_price when displaying the results to show the correct price to the user.

However if the seller does not give an alt-price to all of his products, I’m now displaying the product with the price from A, when in fact I DON’T want to display products from this seller which do not have a pricelist entry at all (think regional assortment).

So if user X has a pricelist “abc” and seller 123 has 500 products, 200 of which are on the pricelist “abc”, I only want to display the 200 products and not 500 with 200 in the correct price.

I tried to use B.alt_price != 0 in the LEFT JOIN, but this doesn’t help, because all items on there have a price.

Question
Is there a way to do this in the actual search or do I have to do it in the results loop, which I’m not really keen on doing.

  • 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-07T16:46:58+00:00Added an answer on June 7, 2026 at 4:46 pm

    Ok. Finally found the solution.

    The problem is, the search will contain multiple sellers, some of whome use pricelists and some who don’t.

    • If I do an INNER JOIN on pricelists B, I will not get the products of sellers who don’t use pricelists as they will not be have any entry in B.
    • If I do a LEFT JOIN on pricelists B, all entries will have either NULL or pricelist B values, so when I’m searching for a seller who uses pricelists for some of his products, I will always get his full range, regardless of alt_price specified
    • If I try to filter these unwanted records (seller uses pricelists, exclude products which are not on it), by adding B.alt_price != 0 to the WHERE clause, I’m also excluding all products from sellers not using pricelists.

    I solved it like this:
    – I’m having to construct this line anyway:

    LEFT JOIN pricelists B ON
           // dynamic construct depending on number of sellers using pricelists matched to user
                B.seller = A.seller 
            AND B.ean = A.ean 
            AND B.alt_price != 0
    
    • So I created another variable, that includes all seller IDs who use pricelists and are applicable to this user. Looks like this:

      123,456,789…

    • I add this to the WHERE clause:

      AND ( IF( A.seller IN ( 123,456,789… ), B.alt_price IS NOT NULL,1 ) )

    This way, I’m checking
    (a) if the record is from a pricelist seller applicable to the user, and
    (b) if that’s the case, the records must not have a NULL value in the b.alt_price, which records not being on the pricelist will have, since sql adds NULL to all records not on the pricelist B when LEFT JOINING.

    That was difficult…

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I have two tables with like below codes: Table: Accounts id | username |
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.