SELECT IFNULL(image_s4,CONCAT(stock.id,'-s4.jpg')) AS image, CONCAT(stock.id,'-s5.jpg') AS s5image, title, m.media_desc as media, name, price, stock.id, dimensions, sale_status, artist_id, CONCAT(UPPER(LEFT(c.country,1)),'P',stock.id) AS catno FROM stock LEFT JOIN mediatype AS m ON m.id = stock.media_type LEFT JOIN artist AS artist ON artist.id = stock.artist_id LEFT JOIN country AS c ON c.id = artist.nationality WHERE stock.id = 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 '' at line 8