SQL collection of records



  • Hey, guys, tell me how to get a grading on the arrivals. I have two tables, one allowed tags{id,objid,name} second objects{id,title,text}; Every record allows objects to be able to be any bulb in different connections under the id. Use the request:

    SELECT o . * FROM tags AS t, objects AS o WHERE (t.name LIKE '%something1%'OR t.name LIKE '%something2%' OR...OR t.name LIKE '%somethingX%')AND t.objid = o.id

    but as a result, kill a similar line(s) to be duplicated and quarrel to DESC



  • SELECT o.id, o.title, o.text, count(*) as qty FROM tags AS t, objects AS o WHERE (t.name LIKE '%something1%'OR t.name LIKE '%something2%' OR...OR t.name LIKE '%somethingX%')AND t.objid = o.id
    group by o.id, o.title, o.text
    order by qty desc
    

    http://www.sql-tutorial.ru/ru/book_group_by_clause.html


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2