Jump to content

Recommended Posts

MY QUERY

SELECT gpb.shop_id,gpb.brand,gpb.image,gpb.model,gpb.link_url,gpb.offer_name,gpr.name,gpr.url,gpr.products,gpr.list
FROM `getpriceproducts` gpb, `getpriceretailer` gpr
WHERE `offer_name` LIKE '%washing%machine%'
OR `model` LIKE '%washing%machine%'
and shop_id = id



http://www.getprice.com.au/buy-best-washing-machine.htm

I have access to a feed and have loaded this into the database.  I am basically trying to query the two tables getpriceproducts and getpriceretailer to obtain the same results as they do.

 

trouble is its returning half a million rows, I cannot figure out how they are grouping the tables together to show say 8 prices for the same product.

 

 

here is the query I have so far testing against the keyword "washing machine" and an example of the getprice results for the same keyword

 

 

Link to comment
https://forums.phpfreaks.com/topic/287685-stuck-on-a-mysql-query/
Share on other sites

You need to specify the join condition between getpriceproducts and getpriceretailer tables, which is probably the retailerid. If you don't you join every record in one table with every record in the the other, hence the huge output

 

It is also more efficient to use an explicit JOIN statement. instead of "..FROM A, B.."

use

... FROM A INNER JOIN B ON A.x = B.y

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.