By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create Table Category (
Id int,
Libelle varchar(10),
Description varchar(10));
insert into Category values
(1,'Animals','dogs'),
(2,'Kids','games'),
(3,'Kids plus','clothes');
create Table Product (
Id int,
Name varchar(10),
Category_Id int);
insert into Product values
(1 ,'aaa kkk', 2),
(2 ,'bbb kkk', 2),
(3 ,'bbb kkk', 1),
(4 ,'bbb kkj', 1),
(5 ,'bbb kkk', 3);
select
p.Id,p.Name,
c.Id,c.Libelle,c.Description
from Category c
JOIN Product p on p.Category_Id = c.Id
where p.Name LIKE '%kkk%'
AND
c.Libelle NOT REGEXP '^Kids$'
AND
c.Description NOT REGEXP '^Kids$'
Id | Name | Id | Libelle | Description |
---|---|---|---|---|
3 | bbb kkk | 1 | Animals | dogs |
5 | bbb kkk | 3 | Kids plus | clothes |