Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I was working on this FOREVER...
#1
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?
[Image: chaosthegreat.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)