CTE (Common Table Expressions – http://msdn.microsof…y/ms190766.aspx) are not supported in MySQL- It is a (Microsoft) SQL Server construction. So what problem you experience with SQLyog you would with any client for MySQL. It is the MySQL server that returns the syntax error.
Refer MySQL manual for supported SQL syntax with MySQL: http://dev.mysql.com…sql-syntax.html