oohoohoohooh
Programmer
Hi, I'm trying to set up my own amazon web service. My problem comes from different stores only available to certain countries. Please check for information on which stores are available to which country.
I want to setup my store so that I can easily update these categories on further releases of the amazon webservice as it is forever changing. I have therefore set up a few tables:
amazon_locales:
- amazon_local_id
- amazon_local_name
- code
amazon_cats:
- amazon_cat_id
- amazon_cat_name
amazon_cat_lines:
- amazon_local_id
- amazon_cat_id
The amazon_locales table would contain all the available locals such as US, UK, DE etc and the amazon_cats table would contain all the available stores such as Music, DVD, VHS etc. The amazon_cat_lines table provides the link between the locale and the cat to see if it is available for any given locale (if a record exits it does if not then it is not).
Hope all is clear so far. I have now setup an additional table which is the categories table which provides the categories the site will use. This allows me to setup categories and sub categories linking to the available amazon_cats (stores). Here is its structure:
cats:
- cat_id
- subcat_id (if 0 then it is not a subcat, if it contains a value then it belongs to that cat)
- cat_name
- amazon_cat_id (this specified the store lookup data from - if this value is 0 then no store selected)
OK now here's my problem. I need to select all the cats (not subcats) to display for a given local (in this example we will use amazon_local_id=1).
I tried:
SELECT c.* FROM cats c LEFT OUTER JOIN amazon_cat_lines acl ON c.amazon_cat_id=acl.amazon_cat_id && acl.amazon_local_id=1 WHERE c.subcat_id=0
I'm sure it is quite close but since I had to use an outer join since the amazon_cat_id value can be 0 it will still return every category even though no record exists in the amazon_cat_lines table to show that it is available to that particular locale.
I know this is alot to take in but I'm sure it has a simple solution and would appreciate it if someone could help. Thanks
I want to setup my store so that I can easily update these categories on further releases of the amazon webservice as it is forever changing. I have therefore set up a few tables:
amazon_locales:
- amazon_local_id
- amazon_local_name
- code
amazon_cats:
- amazon_cat_id
- amazon_cat_name
amazon_cat_lines:
- amazon_local_id
- amazon_cat_id
The amazon_locales table would contain all the available locals such as US, UK, DE etc and the amazon_cats table would contain all the available stores such as Music, DVD, VHS etc. The amazon_cat_lines table provides the link between the locale and the cat to see if it is available for any given locale (if a record exits it does if not then it is not).
Hope all is clear so far. I have now setup an additional table which is the categories table which provides the categories the site will use. This allows me to setup categories and sub categories linking to the available amazon_cats (stores). Here is its structure:
cats:
- cat_id
- subcat_id (if 0 then it is not a subcat, if it contains a value then it belongs to that cat)
- cat_name
- amazon_cat_id (this specified the store lookup data from - if this value is 0 then no store selected)
OK now here's my problem. I need to select all the cats (not subcats) to display for a given local (in this example we will use amazon_local_id=1).
I tried:
SELECT c.* FROM cats c LEFT OUTER JOIN amazon_cat_lines acl ON c.amazon_cat_id=acl.amazon_cat_id && acl.amazon_local_id=1 WHERE c.subcat_id=0
I'm sure it is quite close but since I had to use an outer join since the amazon_cat_id value can be 0 it will still return every category even though no record exists in the amazon_cat_lines table to show that it is available to that particular locale.
I know this is alot to take in but I'm sure it has a simple solution and would appreciate it if someone could help. Thanks