sql server - MSSQL to MYSQL conversion -
this question has answer here:
- create table variable in mysql 6 answers
i have mssql query , convert mysql version. have error in console:
#1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near 'declare @selectedtags table (id int) declare @tagcount int inser' @ line 1
my code below:
declare @selectedtags table (id int) declare @tagcount int insert @selectedtags values (1) insert @selectedtags values (3) insert @selectedtags values (5) select @tagcount = count(*) @selectedtags select p.id product p join producttag pt on pt.productid = p.id join @selectedtags t on t.id = pt.tagid group p.id, p.name having count(pt.tagid) = @tagcount
there no table type in mysql, have create temporary table , insert it.
declare allowed in stored routines only.
set @tagcount use
select count(*) @tagcount temp_table;
Comments
Post a Comment