I need to select all rows from table: Announcements where there are exist rows in table Categories_announcements for user by condition:
Categories_user.category_id = Categories_announcements.category_id
I tried SQL query, see link
It should returns me onlu one row Announcements.id = 1, because user has only one category in Categories_user.category_id.
EDIT:
I have tested SQL that you shared, so this is query:
select *
from `announcements`
where exists (
select 1
from `announcement_category`
inner join `user_category` on `user_category`.`category_id` = `announcement_category`.`category_id`
where `Auser_category`.`user_id` = 1
and `announcement_category`.`announcement_id` = announcements.id
)
It returns me an error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') LIMIT 0, 25' at line 7