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
s.id IN (SELECT prd FROM shpProductFormats WHERE prc > 0...' at line 4[SELECT id
FROM shpProducts s
WHERE
s.id <> AND
s.id IN (SELECT prd FROM shpProductFormats WHERE prc > 0) AND
s.stt IN (SELECT id FROM shpProductStates WHERE purchAllow = 1) AND (
s.id IN (SELECT DISTINCT prd FROM shpProductAuthors WHERE athr IN (SELECT athr FROM shpProductAuthors WHERE athr = ))
)
ORDER BY RAND()]