'select from table with one mandatory condition and tow optional conditions [duplicate]

am trying to make an advanced search form for my site and I want to get only rows with uploaded videos links and check if the title and description is equal to the search query I tried :

SELECT `id` 
FROM `posts` 
WHERE `file` LIKE '%video%' 
AND `title` LIKE '%{$search_query}%' 
OR `description` LIKE '%{$search_query}%';

But in this case, MySQL returns all the rows that contain the search query in their description or title regardless of whether the 'file' column contains "video" or not and I want it to return only matches with video files how can I achieve that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source