此查询工作正常:
SELECT posts.titulo as value,
posts.id as id,
posts.img_src as img,
posts.id_familia,
posts.tiempo,
posts.votos,
familias.clave,
familias.id as fm,
textos.clave,
textos.texto as familia,
FROM posts,familias,textos
WHERE posts.id_familia = familias.id AND familias.clave = textos.clave AND textos.lengua = ".detectarIdioma()."
and posts.id_usuario = $term
ORDER BY posts.id DESC
但是现在我想在评论表中添加有多少评论有一个帖子。
SELECT posts.titulo as value,
posts.id as id,
posts.img_src as img,
posts.id_familia,
posts.tiempo,
posts.votos,
familias.clave,
familias.id as fm,
textos.clave,
textos.texto as familia,
count(comentarios.id)
FROM posts,familias,textos
JOIN comentarios ON comentarios.id_post = posts.id
WHERE posts.id_familia = familias.id AND familias.clave = textos.clave AND textos.lengua = ".detectarIdioma()."
and posts.id_usuario = $term
ORDER BY posts.id DESC
问题是mysql错误是
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 '*) FROM posts,familias,textos JOIN comentarios ON ' at line 12
知道我在这里想念什么吗?