获取mysql错误表'/tmp /#sql_2114_0.MYI'的密钥文件不正确;尝试修复它

时间:2016-01-18 07:48:29

标签: mysql

我修复所有表甚至创建新的,但没有一个帮我修复它。

这是我创建的查询

SELECT books_history.title, books_history.autor, books_history.rating,
books_history.asin, books_history.link, books_history.cat_1,
books_history.cat_2, reduced_book_test.book_asin FROM books_history,
reduced_book_test where books_history.cat_1 = 'Action & Abenteuer' OR
books_history.cat_2 = 'Action & Abenteuer' AND books_history.asin =
reduced_book_test.book_asin ORDER BY rating DESC LIMIT 0, 10

我不确定它是否正确,如果有人可以帮助我真正的帮助。

这是我正在使用的两个表格的结构。table book_history reduced_book_test

我想要的是创建mysql查询所以我可以得到这样的结果有两个表book_history,reduced_book_test共同列是book_history.asin和reduced_book_test.book_asin我需要过滤来自book_history.cat_1和book_history.cat_2的类别。

请帮我解决。

1 个答案:

答案 0 :(得分:1)

使用父表的主键作为连接条件中的公共字段。 您所要做的就是为父表设置一个主键即使它是'asin',也在您的子/依赖表中使用该字段,并根据该字段进行选择。

SELECT books_history.title, books_history.autor, books_history.rating,
books_history.asin, books_history.link, books_history.cat_1, 
books_history.cat_2, reduced_book_test.book_asin 
FROM books_history 
inner join reduced_book_test 
on books_history.asin = reduced_book_test.book_asin 
where books_history.cat_1 = 'Action & Abenteuer' 
OR books_history.cat_2 = 'Action & Abenteuer'  
ORDER BY rating DESC LIMIT 0, 10