I have below search script to perform multiple column search in table, but the results is not as expected, few of data rows are show with status = new
and company name = demo
, can someone please point out what is wrong for below query? what is more accurate query to perform a search with these conditions?
SELECT * FROM messageboard AS m LEFT JOIN users AS u ON m.author_id=u.user_id
WHERE m.status='approved'
AND u.user_email LIKE '%demo%'
OR u.company_name LIKE '%demo%'
OR m.subject LIKE '%demo%'
ORDER BY m.posted_time DESC
Thanks a lot.