此查询工作正常,但执行时间过长。它在 xampp localhost 上运行。
只是我想选择webpage.id where word= "somthing" AND word != " another somthing"
我的意思是,如果您在 Google 上搜索,您可以使用该快捷方式“python -cat”,这意味着获取所有包含单词“python”但不包含单词“cat”的链接。
SELECT webpage.title, word.title, word.id, webpage.title, webpage.id, webpage.link, wordpage.wordID, wordpage.id, wordpage.type, wordpage.pageID
FROM SE_word AS word
INNER JOIN se_wordpage AS wordpage ON wordpage.wordID = word.id
INNER JOIN se_webpage AS webpage ON wordpage.pageID = webpage.id
WHERE word.title = "python"
AND webpage.id NOT IN (
SELECT WP.id
FROM se_webpage AS WP
INNER JOIN se_wordpage AS WOP ON WP.id = WOP.pageID
INNER JOIN se_word AS W ON W.id = WOP.wordID
WHERE W.title = "cat"
)
GROUP BY webpage.id
ORDER BY webpage.title DESC
例如,它是一个简单的搜索引擎
table se_Word is
**id | title**
1 | "game"
2 | "java"
3 | "python"
table se_WebPage is
**id | title**
1 | "www.ABCDEF.com"
2 | "www.ABCDR.net"
3 | "www.ABC.com"
table se_WordPage is
**id | pageID | wordID**
1 | 1 | 1
2 | 2 | 3
3 | 3 | 3
3 | 2 | 1
结果应该是webpage.id = 3
这是创建脚本是否有任何优化?
提前致谢。