Select without repeating data

1

I'm developing a site for a musical project and I'm having difficulty with select, it's the following, I have 2 tables a call album that contains cd information (artwork, disc title, songs name, etc), the other table calls album_links that has the links from where the cd will be available to buy (amazon, bandcamp, itunes, etc.).

I made a select in the album table and all information appears normally, but in the table album_links when it is done select the data if it has more than one cd.

The idea is to only show the links for each cd registered. Ex:

CD 1 link1 link2 link3

CD 2 link1

The only table that has foreign key (referring to the album table) is the album_links table, already tried to make an inner join between the two tables, and also other selects, but for now without success.

I had the same problem in another project when I went to develop a photo gallery, the data repeated and I still could not solve this problem either.

Does anyone have an idea what it can be?

Here is the Front End code

public function listing() {
    $ListRelease = new ModelsRead();
    $ListRelease->ExeRead('album');
    $this->Result = $ListRelease->getResult();
    return $this->Result;
}

public function listingLinks() {
    $ListReleaseLink = new ModelsRead();
    $ListReleaseLink->ExeRead('album_links');        
    $this->Result = $ListReleaseLink->getResult();
    return $this->Result;
}

In both functions ExeRead does: SELECT * FROM table

The ModelsRead class has the functions

public function ExeRead($Table, $Terms = null, $ParseString = null) {
    if (!empty($ParseString)):
        parse_str($ParseString, $this->Values);
    endif;
    $this->Select = "SELECT * FROM {$Table} {$Terms}";
    $this->ExecuteInstruction();
}
public function fullRead($Query, $ParseString = null) {
    $this->Select = (string) $Query;
    if(!empty($ParseString)):
        parse_str($ParseString, $this->Values);
    endif;
    $this->ExecuteInstruction();
}

Database: mysql

Here is the inner join I tried to do:

public function listingLinks() {
    $ListReleaseLink = new ModelsRead();
    $ListReleaseLink->fullRead("SELECT alblink.*, alb.album_title album FROM 
    album_links alblink
                            INNER JOIN album alb ON alb.id = alblink.album_id");
    $this->Result = $ListReleaseLink->getResult();
    return $this->Result;
}

But he repeats the data, the result I want is for each album to show the respective registered links.

    Tabela album
    id
    album_title
    picture
    album_tracks    
    album_members   
    album_release_date
    producers
    studio
    created
    modified

    Tabela album_links
    id
    name
    picture
    link
    album_id
    created
    modified

In this project I'm using MVC standard

    
asked by anonymous 31.05.2018 / 05:15

1 answer

0

For it not to repeat the data in the inner join you only have to put at the end of the syntax "group by album_id"

    
31.05.2018 / 20:21