You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'and referencia='RTR50608PLAS/IB28'' at line 4 - SELECT articulos.categoriaID, accesorio FROM idebd.articulos inner join categorias on articulos.categoriaID=categorias.categoriaID where subfamiliaID= and referencia='RTR50608PLAS/IB28'