mysql select problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sjors broersen

    #1

    mysql select problem

    can anybody help me with sql problem

    if have this table `link_item_cato `:

    +-----+---------+---------+
    | id | item_id | c ato_id |
    +-----+---------+---------+
    | 1 | 1 | 1 |
    | 2 | 2 | 2 |
    | 3 | 3 | 1 |
    | 4 | 3 | 2 |
    | 5 | 3 | 3 |
    +-----+---------+---------+

    the next thing i want do to is to select the item_id`s where the cats_id`s
    are 1 but not are 2
    then you can make a simple query like this :

    SELECT * FROM `link_item_cato ` WHERE cato_id = 1 && cato_id != 2

    result:
    +-----+---------+---------+
    | id | item_id | c ato_id |
    +-----+---------+---------+
    | 1 | 1 | 1 |
    | 3 | 3 | 1 |
    +-----+---------+---------+

    no the problem i don`t want the row with where item_id is 3 because
    somewhere else in the table
    I sad that item_id 3 also belongs to cato_id 2.

    suggestions?



Working...