MySQL Forums
Forum List  »  German

Subquery
Posted by: T H
Date: May 13, 2019 02:17AM

Hallo

Habe ich der Tabelle 5 Varianten, 5 Filearten und sollte ausgeben pro Person wann das letzte File erfasst wurde

CREATE TABLE `db2files` (
`files_id` int(11) NOT NULL,
`erfassdat` int(11) NOT NULL,
`pe_id` int(11) NOT NULL,
`id_fileart` int(11) NOT NULL
)


CREATE TABLE `db1person` (
`pe_id` int(11) NOT NULL,
`ADR_NAME` varchar(50) NOT NULL
)


Ich suche ein Resultat das so aussieht:

ADR_NAME
erfassdat id_fileart ='1'
erfassdat id_fileart ='2'
erfassdat id_fileart ='3'

Also:
Huber
15.3.2018
20.12.2018
1.3.2019


Was ich hinbringe ist den letzten Datensatz, aber nicht die Aufteilung

SELECT DB1person.pe_id,DB1person.ADR_NAME,
DB2files.erfassdat AS Datum,MIN(DB2files.id_fileart) as id_fileart
FROM DB1person
left join DB2files on DB1person.pe_id=DB2files.pe_id
group by DB1person.pe_id
ORDER BY `id_fileart` DESC

Da bekomme ich
Huber
15.3.2018

Wie kann ich die unterschiedlichen DB2files.id_fileart ins gleiche Resultat bringen?

Danke

Options: ReplyQuote


Subject
Views
Written By
Posted
Subquery
606
T H
May 13, 2019 02:17AM
307
May 13, 2019 03:18AM
311
May 13, 2019 09:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.