$i = 1;$sql = "select name,price,short_description,sku,weight,promotion from catalog_product_flat_'".$i."'". "UNION ALL";$query=$sql.substr(0,$sql.strlen($sql)-9);echo $query;//It seems you have problesm with the concatenation of values in the variable $query. Please inspect it again.