I have a barebones search system that just got more complicated and there are many weird issues going on with it. How can I rewrite this search query to be more accurate and efficient
The tbl_notes table only has the id of the course but to add it to the search I used a inner query to check it too. There are alot of issues with this and I’m not too strong in mysql any help would be appreciated.
TBL_NOTES:
[id][user_id][note_title][note_title][topic][course][note]
TBL_COURSES:
[id][user_id][course_name]
SELECT * FROM `tbl_notes`
WHERE `active` = '0'
AND `valid_note` = '0'
AND `user_id` = '33'
AND `note` LIKE '%biology%'
OR `topic` LIKE '%biology%'
OR `note_title` LIKE '%biology%'
OR `course` IN (SELECT `id` FROM tbl_courses WHERE `course_name` LIKE '%biology%' AND user_id = '33')
ORDER BY id DESC LIMIT 0, 6
Thanks
I would write it like this: