I have the follow tables:
systems
-----------
id
name
price
online
productid
specifications
-------------
id
systemid
type
componentid
quantity
components
-------------
id
name
brand
type
description
I need to filter across these tables with multiple options. Each system has multiple specifications rows, and each 'specifications' row links to it's corresponding 'components' row.
My issue is this:
I need to be able to filter systems by multiple properties based on the table joins. I've been using code that'll allow me 1 search option, but nothing further:
select
`systems`.`id`,
`systems`.`name`,
`specifications`.`type`
from `systems`
join specifications
on `systems`.`id` = `specifications`.`systemid`
join components
on `specifications`.`componentid` = `components`.`id`
where
`specifications`.`type` = 'cpu'
and `components`.`brand` = 'amd'
So, that'll let me do a join where the specifications type is CPU and the brand is AMD, but if I add something else to look for too, like specifications.type ='graphics' AND components.brand = 'nvidia'
it just doesn't work. I think this is inherent in the way joins work, as I've said, I'm having trouble articulating the issue here as I'm quite new to these more complex database transactions and would greatly appreciate being pointed in the right direction!
I'm using CodeIgniter as my framework, and I'd like to try and get the bottom of this via MySQL as opposed to doing it in PHP if it's possible - as I'd like a better understanding of what's going on here.