我编写代码来搜索不同表中的关键字。这是我的代码:
$stmt = $conn->prepare("SELECT DISTINCT rest.*,
MATCH(rest.resname, rest.address) AGAINST(:keyword) as a,
MATCH(cuisine.cuisine) AGAINST(:keyword) as b,
MATCH(recc.recc) AGAINST(:keyword) as c,
MATCH(emenu.menu, emenu.menudesc) AGAINST(:keyword) as d,
MATCH(facilities.fac) AGAINST(:keyword) as e,
MATCH(serv.service) AGAINST(:keyword) as f
FROM rest
INNER JOIN cuisine ON rest.resID = cuisine.resID
INNER JOIN recc ON rest.resID = recc.resID
INNER JOIN emenu ON rest.resID = emenu.resID
INNER JOIN facilities ON rest.resID = facilities.resID
INNER JOIN serv ON rest.resID = serv.resID
WHERE
(
MATCH(rest.resname, rest.address) AGAINST(:keyword)
OR MATCH(cuisine.cuisine) AGAINST(:keyword)
OR MATCH(recc.recc) AGAINST(:keyword)
OR MATCH(emenu.menu, emenu.menudesc) AGAINST(:keyword)
OR MATCH(facilities.fac) AGAINST(:keyword)
OR MATCH(serv.service) AGAINST(:keyword)
)
AND (aktif = :aktif) AND (negeri = :negeri) ORDER BY resID DESC LIMIT :rowsperpage OFFSET :offset");
$stmt->bindValue(':keyword', $_GET["keyword"], PDO::PARAM_STR);
$stmt->bindValue(':negeri', $negeri, PDO::PARAM_STR);
$stmt->bindValue(':aktif', $active, PDO::PARAM_STR);
$stmt->bindValue(':rowsperpage', (int) $rowsperpage, PDO::PARAM_INT);
$stmt->bindValue(':offset', (int) $offset, PDO::PARAM_INT);
$stmt->execute();
此查询涉及6个表。
根据我的想法,我真的认为如果在不同的表中有2个相同的标签,它将返回2个结果。
任何人都可以帮我吗?感谢