Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting unique values as a query result
    primarykey
    data
    text
    <p>I have a many-to-many relation with my database, so I created a sql query which later I will use for search. Now what I want to do is get a unique values from my search result (unique company names).</p> <p>This is my query:</p> <pre><code>SELECT agencies.company ,agencies.website_url ,agencies.STATUS ,agencies.size ,IndustryData.industry_id ,ProfessionData.profession_id ,SectorData.sector_id ,seniorityData.seniority_id ,ZonesData.zone_id FROM agencies LEFT JOIN ( SELECT agencies_industries.agency_id ,agencies_industries.industry_id FROM agencies_industries ) AS IndustryData ON agencies.id = IndustryData.agency_id LEFT JOIN ( SELECT agencies_professions.agency_id ,agencies_professions.profession_id FROM agencies_professions ) AS ProfessionData ON agencies.id = ProfessionData.agency_id LEFT JOIN ( SELECT agencies_sectors.agency_id ,agencies_sectors.sector_id FROM agencies_sectors ) AS SectorData ON agencies.id = SectorData.agency_id LEFT JOIN ( SELECT agencies_seniorities.agency_id ,agencies_seniorities.seniority_id FROM agencies_seniorities ) AS SeniorityData ON agencies.id = SeniorityData.agency_id LEFT JOIN ( SELECT agencies_zones.agency_id ,agencies_zones.zone_id FROM agencies_zones ) AS ZonesData ON agencies.id = ZonesData.agency_id WHERE IndustryData.industry_id = 3 AND ProfessionData.profession_id = 1 </code></pre> <p>The result looks like this:</p> <p><strong>company, website_url, status, size, industry_id, profession_id, sector_id, seniority_id, zone_id</strong></p> <ol> <li>Nine nine.com 1 3 3 1 3 2 1</li> <li>Nine nine.com 1 3 3 1 3 2 5</li> <li>Nine nine.com 1 3 3 1 3 2 8</li> <li>Nine nine.com 1 3 3 1 3 5 1</li> <li>Nine nine.com 1 3 3 1 3 5 5</li> <li>Nine nine.com 1 3 3 1 3 5 8</li> <li>Ten ten.com 2 3 3 1 3 1 1</li> <li>Ten ten.com 2 3 3 1 3 1 3</li> <li>Ten ten.com 2 3 3 1 3 1 7</li> <li>Ten ten.com 2 3 3 1 3 3 1</li> <li>Ten ten.com 2 3 3 1 3 3 3</li> <li>Ten ten.com 2 3 3 1 3 3 7</li> <li>Ten ten.com 2 3 3 1 3 5 1</li> <li>Ten ten.com 2 3 3 1 3 5 3</li> <li>Ten ten.com 2 3 3 1 3 5 7</li> </ol> <p>I would like to get rid of the repeats of the company names. How do I do that?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload