这是我的查询,该查询从数据库中搜索具有名称或电话号码的学生。
select ct.id, c.name as batchname,ct.qualification,ct.fees,ct.email,
ct.email,ct.phone, ct.name, ct.status,ct.notification
from student ct , batch c
where ct.batch_id=c.id and c.status=1
and (ct.name like '%Aniruddha%' or ct.phone like '%Aniruddha%')
问题是,如果学生是,它将获取零行表单数据库
存在于数据库中。我无法识别的查询错误是什么
任何人都可以提供帮助。
最佳答案
请尝试以下方法:
select ct.id, c.name as batchname,ct.qualification,ct.fees,ct.email,
ct.email,ct.phone, ct.name, ct.status,ct.notification
from student ct
left join batch c on ct.batch_id=c.id
where c.status=1
and (ct.name like '%Aniruddha%' or ct.phone like '%Aniruddha%')
关于mysql - mysql查询返回零行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32118354/