I'm using a multi table select statement in mysql to filter query from some user inputs. The input $_POST values are: 1.zipcode [from locations table] or 2.city [from locations table] and/or 3.on_date [from calendar table] and /or 4.title [from posts table].
我在mysql中使用多表select语句来过滤某些用户输入的查询。输入$ _POST值为:1.zipcode [来自位置表]或2.city [来自位置表]和/或3.on_date [来自日历表]和/或4.title [来自posts表]。
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";
This setup works for the locations. I can enter either a zipcode or a city and the query filters correctly, but the $date and $title values, which are set from the input, retrieve no records.
此设置适用于这些位置。我可以输入邮政编码或城市,并且查询过滤正确,但是从输入设置的$ date和$ title值不会检索任何记录。
Any ideas? or do you need more info? Thanks in advance.
有任何想法吗?或者您需要更多信息?提前致谢。
1 个解决方案
#1
0
You left out tableName in title INNER JOIN posts ON title LIKE '%{$title}%'
你在标题INNER JOIN帖子中遗漏了tableName ON标题LIKE'%{$ title}%'
try tableName.title
.
I don't see anything with the query that will make it not work, but lemme have a look at it again
我没有看到任何查询会使它不起作用,但是lemme再看看它
#1
0
You left out tableName in title INNER JOIN posts ON title LIKE '%{$title}%'
你在标题INNER JOIN帖子中遗漏了tableName ON标题LIKE'%{$ title}%'
try tableName.title
.
I don't see anything with the query that will make it not work, but lemme have a look at it again
我没有看到任何查询会使它不起作用,但是lemme再看看它