DROP TABLE IF EXISTS users, posts, comments;
SET NAMES utf8mb4;
CREATE TABLE users (
id int NOT NULL,
name varchar(50) NOT NULL,
PRIMARY KEY (id),
KEY (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE posts (
id int NOT NULL,
content mediumtext,
user_id int NOT NULL,
PRIMARY KEY (id),
FULLTEXT KEY (content)
) DEFAULT CHARSET=utf8mb4;
CREATE TABLE comments (
id int NOT NULL,
user_id int NOT NULL,
post_id int NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO users VALUES    (1, "Alice"),
(2, "Bob"),
(3, "Calros");
INSERT INTO posts VALUES    (1, "Hello!", 1),
(2, "World!", 2),
(3, "Great!", 3);
INSERT INTO comments VALUES (1, 1, 1),
(2, 2, 1),
(3, 3, 3);
SELECT *
FROM comments
INNER JOIN posts
ON posts.id = comments.post_id AND
MATCH (posts.content) AGAINST ("Hello!" IN BOOLEAN MODE)
INNER JOIN users
ON users.id = comments.user_id AND
users.name = "Alice";
id	user_id	post_id	id	content	user_id	id	name
1	1	1	1	Hello!	1	1	Alice
DROP TABLE users, posts, comments;
