I have a MSSQL query and would like to convert it to MySQL version. But I have an error in my console:
#1064 - 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 'DECLARE @selectedTags TABLE (ID int) DECLARE @tagCount int INSER' at line 1
My code below:
DECLARE @selectedTags TABLE (ID int)
DECLARE @tagCount int
INSERT INTO @selectedTags VALUES (1)
INSERT INTO @selectedTags VALUES (3)
INSERT INTO @selectedTags VALUES (5)
SELECT @tagCount = COUNT(*) FROM @selectedTags
SELECT
P.ID
FROM Product P
JOIN ProductTag PT
ON PT.ProductID = P.ID
JOIN @selectedTags T
ON T.ID = PT.TagID
GROUP BY
P.ID,
P.Name
HAVING COUNT(PT.TagID) = @tagCount