0

我在 mysql 中使用多表选择语句来过滤来自某些用户输入的查询。输入 $_POST 值为:1.zipcode [来自位置表] 或 2.city [来自位置表] 和/或 3.on_date [来自日历表] 和/或 4.title [来自帖子表]。

FROM table_many
INNER JOIN posts ON posts.title LIKE '%{$title}%'
INNER JOIN users ON users.user_id = posts.user_id
INNER JOIN locations ON locations.post_id = posts.post_id AND locations.city = '$city[0]'
LEFT JOIN calendar ON calendar.post_id = posts.post_id AND calendar.on_date = '$date'
LEFT JOIN uploads ON posts.post_id = uploads.post_id 
WHERE table_many.cat_id = '$row_cat[0]' AND table_many.post_id = posts.post_id";

此设置适用于这些位置。我可以输入邮政编码或城市并且查询过滤器正确,但是从输入中设置的 $date 和 $title 值不检索任何记录。

有任何想法吗?还是您需要更多信息?提前致谢。

4

1 回答 1

0

您在标题中遗漏了 tableNameINNER JOIN posts ON title LIKE '%{$title}%'

试试 tableName.title

我没有看到任何会使其无法正常工作的查询,但请让我再看一下

于 2013-01-22T20:30:16.003 回答