搜索栏带有文本字段和下拉列表。
用户输入文本并选择一门类(class)然后提交。
我需要获取那些具有用户选择的相同类(class)的行的结果。
my db have two tables currently
1.content_ref_table with fields
title,description,content_url,course_id(fk)
2.course_ref_table with columns
course_id(pk),courses
我想出了这个查询,但我猜 mysql 不支持 like 和 in 运算符,建议我一些查询
select title,description,content_url from content_ref_table where title like '%eco%' and course_id in (select course_id from course_ref_table where courses = 'b.com'
最佳答案
尝试在表上使用连接:
select c.title,c.description,c.content_url
from content_ref_table c inner join course_ref_table cf on c.course_id =cf.course_id
where c.title like '%eco%' and cf.courses = 'b.com'
关于mysql - 搜索栏查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37584686/