这是我的查询,它使用姓名或电话号码从数据库中搜索学生。
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%')
问题是,如果学生是,它将获取零行表单数据库 存在于数据库中。什么是查询中的错误我无法识别请 任何人都可以提供帮助。
答案 0 :(得分:1)
请试试这个:
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%')