gpt4 book ai didi

php - NOT IN 不工作 MYSQL

转载 作者:行者123 更新时间:2023-11-29 19:45:25 25 4
gpt4 key购买 nike

我正在尝试使用搜索查询在我的网站上提供搜索功能,但我不希望获得具有 contestId='-1'电影

这是我的搜索查询:

SELECT * FROM film WHERE  MATCH (title, otherInfo, inspiration, description,directedBy,
keywords,producer) AGAINST ('$searchresults' IN NATURAL LANGUAGE MODE )
and contestId not in (select contest_id from contest where contest_id !='-1' )
OR title LIKE 'ho%' OR title LIKE '%ho' and isApproved=1 order by film_id desc limit 1

仍然通过 contestId='-1' 获得结果。

请帮忙。提前致谢。

最佳答案

SELECT   *
FROM film
WHERE MATCH (title, otherinfo, inspiration, description,directedby, keywords,producer) against ('$searchresults' IN NATURAL language mode )
AND contestid NOT IN
(
SELECT contest_id
FROM contest
WHERE contest_id ='-1' )
AND (
title LIKE 'ho%'
OR title LIKE '%ho' )
AND isapproved=1
ORDER BY film_id DESC
LIMIT 1

几个错误

  • 从竞赛 WHERE racing_id !='-1' 中选择 racing_id 应为 从竞赛 WHERE racing_id ='-1' 中选择竞赛_id
  • AND racingId NOT IN (... ) OR title LIKE 'ho%' OR title LIKE '%ho' .... 即使有 contestId = - 也将包含记录1.. title LIKE 'ho%' 或 title LIKE '%ho' 应包含在 AND 内。就像AND(标题LIKE'ho%'或标题LIKE'%ho')

关于php - NOT IN 不工作 MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41032085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com