By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE `table` (
`ID` INTEGER,
`detail_id` INTEGER,
`detail_value` VARCHAR(20),
`book_id` INTEGER
,
FULLTEXT idx (detail_value)
);
INSERT INTO `table`
(`ID`, `detail_id`, `detail_value`, `book_id`)
VALUES
('1', '11', 'Warszawa', '103'),
('2', '14', 'Grażyńskiego', '123'),
('3', '11', 'st.Warszawa m', '123'),
('4', '14', 'Michała Grażyńskiego', '222'),
('5', '11', 'Warszawa', '222'),
('6', '14', 'Katowicka', '103'),
('7', '9', '923', '23'),
('8', '12', '432424', '23'),
('9', '14', 'Przykładowa', '23'),
('10', '11', 'Warszawa', '23');
SELECT * FROM `table` WHERE (detail_id = 11 AND MATCH (detail_value) AGAINST ('*warszawa*' IN BOOLEAN MODE))
AND EXISTS (SELECT 1 FROM `table` WHERE detail_id = 14 AND MATCH (detail_value) AGAINST ('*rażyń*' IN BOOLEAN MODE))
SELECT * FROM `table` WHERE (detail_id = 11 AND MATCH (detail_value) AGAINST ('*warszawa*' IN BOOLEAN MODE))
ID | detail_id | detail_value | book_id |
---|---|---|---|
1 | 11 | Warszawa | 103 |
3 | 11 | st.Warszawa m | 123 |
5 | 11 | Warszawa | 222 |
10 | 11 | Warszawa | 23 |
SELECT 1 as test FROM `table` WHERE detail_id = 14 AND MATCH (detail_value) AGAINST ('*rażyń*' IN BOOLEAN MODE)