mysql - Subquery or INNER JOIN? -
I have 3 tables that represent emails like attachments, accordingly, there are zero, one or more attachments in the email .
Three tables email ,
attachments and
files .
Email - Each email is mentioned in an email and has a message id
attachment - each line There can be a message ID and a file ID with multiple lines with the same message ID.
files - Each file is referenced in a file and it has fileID and file size (size) in it
I get a result in mysql I am trying to list the email ID and the total size of all the files and no success. I files using
SUM (size) and a
INNER JOIN I can get a total size, but I do not have an e-mail ID and a list of total file size Can writing.
Should it use multiple
INNER JOIN S?
INNER JOIN and a subquery? And then a
group B ? Subquery and then a
IN even one direction would be really useful.
Manipulation in PHP seems ridiculously expensive.
Many thanks!
Michael Elkan