```
SELECT links.* 
FROM links
INNER JOIN (
  SELECT keywords_links.link_id
  FROM keywords_links
  INNER JOIN keywords ON keywords_links.keyword_id = keywords.id
  WHERE keywords.keyword
  IN ("facebook",  "google", "apple")
  GROUP BY keywords_links.link_id
  ) t
ON links.id = t.link_id

```

This returns the links that match a keyword(s). I have 3 tables: `links`, `keywords`, and `keywords_links`. The `keywords_links` links the keywords with the links.

How can I make this query more efficient? I'm inexperienced with MySQL so I had to use basic MySQL commands to create this query.

Tables (only relevant info displayed): 

links:

```
CREATE TABLE IF NOT EXISTS `links` (
  `id` int(11) NOT NULL auto_increment,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `url` (`url`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=337789 ;

```

keywords\_links:

```
CREATE TABLE IF NOT EXISTS `keywords_links` (
  `keyword_id` int(11) NOT NULL,
  `link_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

```

keywords:

```
CREATE TABLE IF NOT EXISTS `keywords` (
  `id` int(11) NOT NULL auto_increment,
  `keyword` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `sort` (`id`,`keyword`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=60363 ;

```