Mezun bilgi sistemi için sorgulama yapmaya çalışıyorum. Yazdığım sorgu ise şu şekilde.
SELECT
AlumniAcademicInfo.academic_info_id,
Alumni.name,
`surname`,
`department_name`,
DATE_FORMAT(`grad_date`, '%d %b %Y') AS grad_date,
`grad_type_name`,
AlumniEducationType.name as edu_type,
`email`,
`academic_name`
FROM
mebis.Alumni,
mebis.UnitDepartment,
mebis.AlumniAcademicInfo,
mebis.AlumniGradType,
mebis.UnitAcademic,
mebis.AlumniEducationType
WHERE
AlumniAcademicInfo.alumni_id = Alumni.alumni_id
AND AlumniAcademicInfo.department_id = UnitDepartment.department_id
AND AlumniAcademicInfo.grad_date IS NOT NULL
AND AlumniAcademicInfo.university_id = 1
AND AlumniAcademicInfo.grad_type_id = AlumniGradType.type_id
AND AlumniAcademicInfo.faculty_id = UnitAcademic.academic_id
AND AlumniAcademicInfo.education_type = AlumniEducationType.id
AND AlumniAcademicInfo.grad_type_id LIKE '%%'
AND AlumniAcademicInfo.faculty_id LIKE '%1%'
AND AlumniAcademicInfo.department_id LIKE '%%'
AND Alumni.name LIKE '%%'
AND Alumni.surname LIKE '%%'
AND AlumniAcademicInfo.education_type LIKE '%%'
AND AlumniAcademicInfo.grad_date BETWEEN '' AND curdate()
ORDER BY Alumni.alumni_id DESC
LIMIT 0,10
Yalnız sıkıntı şu; sorguda da gösterildiği üzere like operatöründen dolayı id'sinin içerisinde 1 olan bütün fakülteleri getiriyor. 10 gibi 11 gibi 171 gibi..
Eğer like operatörünü kullanmazsam bu sefer de faculty_id boş bırakıldığında hiçbir sorgu çalışmıyor.
Bu sorunu nasıl çözebilirim?