我有这个查询工作:
SELECT posts.titulo as value,
posts.id as id
FROM posts,familias,textos
WHERE
lower(titulo) LIKE 'my title'
AND posts.id_familia = familias.id $familiaQuery
AND familias.clave = textos.clave
AND textos.lengua = 1
GROUP by posts.id
ORDER by count(*) desc
但我想添加标签搜索
SELECT posts.titulo as value,
posts.id as id
FROM posts,familias,textos
LEFT JOIN tags_map ON tags_map.id_post = posts.id
LEFT JOIN tags ON tags_map.id_ing = tags.id
WHERE
tags.nombre LIKE 'php'
AND lower(titulo) LIKE 'my title'
AND posts.id_familia = familias.id $familiaQuery
AND familias.clave = textos.clave
AND textos.lengua = 1
GROUP by posts.id
ORDER by count(*) desc
但是我得到了这个错误Unknown column 'posts.id' in 'on clause'
我不明白,这个领域一直都在那里,
为什么它无法找到它?
答案 0 :(得分:2)
仅使用来自clause
无逗号
SELECT posts.titulo as value,
posts.id as id
FROM posts
JOIN familias ON posts.id_familia = familias.id
JOIN textos ON familias.clave = textos.clave
LEFT JOIN tags_map ON tags_map.id_receta = posts.id
LEFT JOIN tags ON tags_map.id_ing = tags.id
WHERE
tags.nombre LIKE 'php'
AND lower(titulo) LIKE 'my title'
$familiaQuery
AND textos.lengua = 1
GROUP by posts.id
ORDER by count(*) desc
答案 1 :(得分:0)
你可能会混淆语法。
我认为您可以将查询包装在子查询中,以防您想要保留它:
q