查询从URL路径获取多个结果

时间:2015-09-05 09:00:00

标签: mysql

来自网址' http://www.example.com/community/teams/photo-gallery'。使用路径/community/teams/photo-gallery如何查询数据库以获取菜单的结果。请注意,菜单slug不是唯一的。

这意味着只显示communityteamsphoto-gallery的结果。

这是我的尝试

SELECT * FROM menu WHERE menu_slug = 'community' AND menu_slug = 'teams' AND menu_slug = 'photo-gallery'

此查询无法在我的情况下工作

SELECT * FROM menu WHERE menu_slug = 'community' OR menu_slug = 'teams' OR menu_slug = 'photo-gallery'

数据库结构 enter image description here

2 个答案:

答案 0 :(得分:0)

尝试:

SELECT * FROM menu WHERE menu_slug = 'community' OR menu_slug = 'teams' OR menu_slug = 'photo-gallery';

OR

SELECT * FROM menu WHERE menu_slug IN ('community', 'teams', 'photo-gallery');

答案 1 :(得分:0)

就是这样吗? o.o

SELECT * FROM menu WHERE menu_slug = 'community' OR menu_slug = 'teams' OR menu_slug = 'photo-gallery'

或者你在说这个? htaccess url rewriting, ignoring files