我正在尝试为一个页面编写一个搜索函数,有许多表与我的特许经营表相关,并通过特许经营表id连接。因此城市的名称可以在城市表中,但城市与位置表绑定,位置表与特许经营表绑定。
我们编写了一个内部连接,它确实选择了正确的行,但是如果在多个表或一个表的多个位置中找到了该术语,则每次找到该术语时,它都会返回一行。有没有办法限制这一点。我在想一个团体会这样做,但不知道我会说“团体特许经营。特许经营id”
SELECT * FROM franchises
INNER JOIN
locations
ON
locations.franchise_id = franchises.franchise_id
INNER JOIN
operators
ON
operators.operator_id = franchises.operator_id
INNER JOIN
state_owners
ON
state_owners.state_owner_id = franchises.state_owner_id
WHERE
franchises.franchise_name LIKE :term OR
franchises.franchise_status LIKE :term OR
locations.location_name LIKE :term OR
locations.location_state LIKE :term OR
operators.operator_first_name LIKE :term OR
operators.operator_last_name LIKE :term OR
operators.operator_id LIKE :term OR
state_owners.state_owner_first_name LIKE :term OR
state_owners.state_owner_last_name LIKE :term OR
state_owners.state_owner_owned_state LIKE :term
暂无答案!
目前还没有任何答案,快来回答吧!