You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND items.activ GROUP BY b.bid' at line 1SELECT b.bid, b.bname, b.bnameasc FROM items INNER JOIN brands b ON (b.bid = items.bid) WHERE items.cid_bc = AND items.activ GROUP BY b.bid