![]() |
I was working on this FOREVER... - Printable Version +- 2DWorlds Forums (http://2dworlds.buildism.net/forum) +-- Forum: Off Topic (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=5) +--- Forum: Programming (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=30) +--- Thread: I was working on this FOREVER... (/showthread.php?tid=7869) |
I was working on this FOREVER... - Chaos - 08-10-2011 And I get this error: NOTE: I forgot if I had to use dots or commas, so this is what I got. [lua] function get_posts(){ $sql = "SELECT `posts`.`post_id` AS `id` `posts`.`post_title` AS `title`. LEFT(`posts`.`post_body`. 512) AS `preview`. `posts`.`post_user` AS `user`. DATE_FORMAT(`posts`.`post_date`. '%d/%m/%y') AS `date`. `comments``total_comments`. DATE_FORMAT(`comments`.`last_comment`. '%d/%m/%y') AS `last_comment` FROM `posts` LEFT JOIN ( SELECT `post_id` COUNT(`comment_id`) AS `total_comments`. MAX(`comment_dat`) AS `last_comment` FROM `comments` GROUP BY `post_id' ) AS `comments` ON `posts`.`post_id` = `comments`, `post_id` ORDER BY `posts`.`post_date` DESC"; $posts = mysql_query($sql); $rows = array(); } [/lua] Now, that's the code. But if I put the main part (where I assign aliases) it gives me this error when I check it for errors: {"success":false,"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 '`posts`.`post_title` AS `title`.\n LEFT(`posts`.`post_body`. 512) AS ' at line 3<\/div>"} ---------------------------------------------------------------------- I'm pretty new to sql so I was using that part as a tutorial and it took forever. Help anyone? |