By reproducing your model, after having tried by all means to indicate the structure of your tables, you can verify that if the data is good there is no problem in obtaining the expected results.
For example, in a design where client 1 has two videos, the following query:
SELECT
c.cliente_id,
c.cliente_nom,
v.video,
f.foto
FROM cliente_20180725 c
INNER JOIN video_20180725 v ON c.cliente_id=v.cliente_id
INNER JOIN full_20180725 f ON c.cliente_id=f.cliente_id ;
Throw the following result:
cliente_id cliente_nom video foto
-------------------------------------------------------------------
1 Cliente 1 Vídeo 1 Cliente 1 foto1.jpg
1 Cliente 1 Vídeo 2 Cliente 1 foto1.jpg
2 Cliente 2 Vídeo 1 Cliente 2 foto2.jpg
3 Cliente 3 Vídeo 1 Cliente 3 foto3.jpg
Neither do you know exactly what you want. If for example you need to group the videos by client, etc.
All this can be done with relative ease, as long as you are clear in explaining the expected results.
Applying a certain order is also easy.
Test data
These are the data that I used. It is a minimum example, it does not have restrictions of uniqueness or established indexes.
If I have not understood the data model well or if there is something that is not clear, you can indicate it in a comment.
I hope it is useful and helps to clarify or solve the problem.
SEE DEMONSTRATION IN REXTESTER
CREATE TABLE IF NOT EXISTS cliente_20180725
(
cliente_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
cliente_nom VARCHAR(50)
)ENGINE=INNODB;
INSERT INTO cliente_20180725 (cliente_nom) VALUES
('Cliente 1'),
('Cliente 2'),
('Cliente 3'),
('Cliente 4')
;
CREATE TABLE IF NOT EXISTS video_20180725
(
video_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
cliente_id INT,
video VARCHAR(50),
FOREIGN KEY (cliente_id) REFERENCES cliente_20180725(cliente_id)
ON UPDATE CASCADE ON DELETE CASCADE
)ENGINE=INNODB;
INSERT INTO video_20180725 (cliente_id,video) VALUES
(1,'Vídeo 1 Cliente 1'),
(1,'Vídeo 2 Cliente 1'),
(2,'Vídeo 1 Cliente 2'),
(3,'Vídeo 1 Cliente 3')
;
CREATE TABLE IF NOT EXISTS full_20180725
(
full_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
cliente_id INT,
foto VARCHAR(50),
FOREIGN KEY (cliente_id) REFERENCES cliente_20180725(cliente_id)
ON UPDATE CASCADE ON DELETE CASCADE
)ENGINE=INNODB;
INSERT INTO full_20180725 (cliente_id,foto) VALUES
(1,'foto1.jpg'),
(2,'foto2.jpg'),
(3,'foto3.jpg'),
(4,'foto4.jpg')
;
SELECT
c.cliente_id,
c.cliente_nom,
v.video,
f.foto
FROM cliente_20180725 c
INNER JOIN video_20180725 v ON c.cliente_id=v.cliente_id
INNER JOIN full_20180725 f ON c.cliente_id=f.cliente_id
ORDER BY c.cliente_id LIMIT 0,25;
EDITION
If you want to group by client, you can write the query like this:
SELECT
c.cliente_id,
c.cliente_nom,
GROUP_CONCAT(v.video SEPARATOR '|') videos,
f.foto
FROM cliente_20180725 c
INNER JOIN video_20180725 v ON c.cliente_id=v.cliente_id
INNER JOIN full_20180725 f ON c.cliente_id=f.cliente_id
GROUP BY c.cliente_id,f.foto ORDER BY c.cliente_id
LIMIT 0,25;
This query will bring you one row for each client and the videos grouped by a |
separator, which you can later break down by programming.
cliente_id cliente_nom videos foto
----------------------------------------------------------------------------------------------
1 Cliente 1 Vídeo 2 Cliente 1|Vídeo 1 Cliente 1 foto1.jpg
2 Cliente 2 Vídeo 1 Cliente 2 foto2.jpg
3 Cliente 3 Vídeo 1 Cliente 3 foto3.jpg