Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

query to print products (mysql syntax problem)


Recommended Posts

Hi,

 

I've got a query to list and print all the items in my shop, but now I want list only those from two categories.

 

I add the two last lines to the query, and it crashes. It seems there are two many items to list, and I think mysql is making combination with all the items in category 65 with the rest of the query (because if I delete the last line all runs fine)

 

Any suggestions?

 

Thanks,

 

Arbocenc

 

SELECT products.products_id, categories_name, products_name, products_price, manufacturers_name, products_weight

FROM products, products_description, categories_description, products_to_categories, manufacturers

WHERE products.products_id = products_to_categories.products_id 

AND products_to_categories.categories_id = categories_description.categories_id 

AND products.products_id = products_description.products_id

AND products.manufacturers_id = manufacturers.manufacturers_id

AND products_status='1' 

AND products_description.language_id='4'

AND categories_description.language_id='4'

AND categories_description.categories_id='64' 

[b]OR categories_description.categories_id='65'[/b]

[/b]

[email protected]

www.delaterra.net

organic food in Catalonia

Link to comment
Share on other sites

  • 2 months later...

Fixed. The problem was the mysql syntax (my skills in mysql are near zero :-(

 

Solution: with a parethesis ()

 

The right query is

 

SELECT products.products_id, categories_name, products_name, products_price, manufacturers_name, products_weight

FROM products, products_description, categories_description, products_to_categories, manufacturers

WHERE products.products_id = products_to_categories.products_id

AND products_to_categories.categories_id = categories_description.categories_id

AND products.products_id = products_description.products_id

AND products.manufacturers_id = manufacturers.manufacturers_id

AND products_status='1'

AND products_description.language_id='4'

AND categories_description.language_id='4'

AND (categories_description.categories_id='64'

OR categories_description.categories_id='65')

 

See you later :-)

 

Joan

[email protected]

www.delaterra.net

organic food in Catalonia

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...