I'm trying to figure out a way to find an entry or the entries where my keywords (multiple) are present in the category table / category name column .
CREATE TABLE entry (
entryid INTEGER PRIMARY KEY,
title TEXT NOT NULL,
datecreated date NOT NULL
);
CREATE TABLE category (
entryid INTEGER,
categoryid INTEGER PRIMARY KEY,
categoryname TEXT NOT NULL
);
INSERT INTO entry VALUES (1, 'title1', '2022-01-15');
INSERT INTO entry VALUES (2, 'title2', '2022-01-16');
INSERT INTO entry VALUES (3, 'title3', '2022-01-17');
INSERT INTO category VALUES (1, 1, 'categorya');
INSERT INTO category VALUES (1, 2, 'categoryd');
INSERT INTO category VALUES (1, 3, 'categorye');
INSERT INTO category VALUES (2, 4, 'categoryd');
INSERT INTO category VALUES (2, 5, 'categorya');
INSERT INTO category VALUES (2, 6, 'categoryb');
INSERT INTO category VALUES (3, 7, 'categorye');
SELECT DISTINCT entry.* FROM entry,category
WHERE entry.entryid=category.entryid
AND (category.categoryname LIKE '%ye%' AND category.categoryname LIKE '%yd%')
I thought that this would give me entryid=1 but, if I unterstand it correctly, I already limit the query with comparing my first keyword? What would I have to do to search for multiple keywords in one column and get the correct entryid?
Edit: I am using HSQLDB within Libre Office Base. I used the data in this post for a more "standardized" approach and to then adjust the solution to my needs :)