WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

Multiple search issue with MySQL

MellowMarsh

New member

0

0%

Status

Offline

Posts

29

Likes

0

Rep

0

Bits

155

5

Months of Service

0%
Hello friends, I am trying to query the Alumni information system for graduates. The query I have written is as follows:

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

The issue is this: as shown in the query, due to the 'like' operator, it brings all faculties with the number 1 in their IDs, such as 10, 11, 171, etc. If I don't use the 'like' operator, then when the faculty_id is left empty, no query works. How can I solve this problem?
 

249

6,622

6,642

Top