close ad
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Problem! MySQL query with two INNER JOINS and WHERE with two conditions

Thread began 2/03/2010 6:33 am by blackweldermhe400113 | Last modified 2/03/2010 3:12 pm by blackweldermhe400113 | 7540 views | 5 replies


Problem! MySQL query with two INNER JOINS and WHERE with two conditions

I'm thinking this isn't that complicated of an issue, but I can't seem to make it work properly. First, I'm using php and have a total of three tables in my database. The first two tables are simple. The first being the "category" table containing an id and name, and the second being the "collection" table containing again an id and a name. The master table of "products" contains two foreign keys that relate to the id's of both the category and collections tables. Through the dreamweaver recordset panel in advanced mode I'm querying the product table and using two INNER JOINS to combine the category, collection, and products tables together. I'm using a WHERE statement to pull two parameters with an OR. Example code below.

FROM product INNER JOIN category ON idcategory_product=id_category INNER JOIN collection ON idcollection_product=id_collection
WHERE idcategory_product=colname || idcollection_product=colname2
ORDER BY id_product DESC


Name: colname
Type: numeric
Default Value: 1
Runtime Value: $_GET['id_category']

Name: colname2
Type: numeric
Default Value: 1
Runtime Value: $_GET['id_collection']

What I'm trying to do is set the navigation on the index page to jump to the products page and pull the appropriate content. So, when a link in the category column on the index page is selected it will jump to a products page and pull all products of that category and the same with the collections, when a collection is selected it will jump to the same products page and list all items within that collection. The nav on the index is being pulled dynamically from the above mentioned category and collections tables. It is then linked to the products page with set parameters for the id of the given table.

The above query seems to work fine with just one of the WHERE conditions but when I try and set both it just wants to dump all data entries in descending order and not filter at all.

Does anyone have any ideas on how to make this work properly? I should be able to fit it all into the same query.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...