I have a query and I only want to use the where conditions if the parameters are not null or empty strings.
select
users.user_id,
users.fname,
users.lname,
Certifications.certName,
skills.skillName
from users
left join Certifications on users.user_id = Certifications.user_id
left join specializations on users.user_id = specializations.user_id
left join skills on skills.user_id = skills.user_id
where
(Certifications.certName is not null and Certifications.certName like 'CCNA Routing and Switching') or
(skills.skillName is not null and skills.skillName like '') or
(users.location is not null and users.location like '')
group by users.user_id
So if the search term for skillName and location is empty I don't want to include those in the where clause.
($searchTerm != '' AND skills.skillName like '$searchTerm')?