i have got a problem with this query.
update table1 as a
left join (
select count(*) as 'rec' from table2 group by isin having rec<100 )
table2 as h on a.isin=h.isin
set a.nohist='1'
i would like to count rows per group, ask if they the count is smaller than 100 an set a flag in table 1.
i get alway an error:
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 'as h on a.isin=h.isin set a.nohist='1'' at line 4
could you help me?
thx br
You are setting the alias for the subselect result to be
table2and then you “realias” thattable2toh. On top of that you try to join tablehandabyisin.You need to select
isininside the subselect if you want to be able to join against that table with the other two tables.