【发布时间】:2010-11-08 17:07:21
【问题描述】:
我有 3 个表事件、位置、事件位置。事件可以有多个位置。 位置表有纬度、经度、hasGeocode 字段。
所以对于关键字“hello world”
对事件表的简单查询变为
Select * from event where keywords like '%hello%' OR keywords like '%world%'
但是如果用户输入了他们的位置,那么我也想在这个查询中包含位置表,以便用户可以指定他们选择的位置,我该怎么做?
所以本质上是 3 种类型的搜索查询
只是关键字
关键字和位置
- 关键字、邻近度和位置
我尝试过这样的事情-
select * from event where keywords like '%hello%' OR
keywords like '%world%' INNER JOIN location ON
location.location_id = event_location.location_id
INNER JOIN
event_location ON event_location.event_id = event.event_id
INNER JOIN 意味着事件必须有一个或多个位置。如果一个事件没有得到任何位置,它就不会出现在搜索结果中。所以请帮助我,我该怎么做?
感谢您的帮助。
【问题讨论】: