sql - How can I return unique rows when using an INNER JOIN in MySQL? -


I have 3 tables: links, keywords, and keyword_link can have many keywords in one link, and one in many links Can be the only keyword. Used to join keyword_link to link and keyword . When I run the following query, several lines of the same link are returned because multiple keywords match. How do I modify this query to return unique rows?

  SELECT links * Include link 'links' from keywords_links.link_id = Add keywords_completions on ID Add keywords to keywords. Keywords = _links.keyword_id where the keyword. Keyword IN ('php', 'sql', 'html', 'css')    

< P> Select the easiest way DISTINCT after select :
  select different links. * ... ...   

But perhaps a more efficient solution would be to write to you that it does not need to make a difference in each column:

  SELECT a. * Join INNER from the link (SELECT a.link_id Inner Join keyword with keyword b on one) Keyword_id = b.id and b.keyword IN ('php', 'sql', 'html', 'css') by group A.link_id) b at a.id = b.link_id    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -