简体   繁体   中英

MYSQL Join table rows and use for php array

I have multiple tables on specific database and each table similar to each other.

Table:

 id     series     folder
  1      Naruto     670
  2      Naruto     671
  3      Naruto     672

Each table has exact setup. Just series name changes. I want to pick up only 1 entry from series row and highest number from the folder row. I will use this data to make it php array and use it for JSON data. Here is my code:

'SELECT naruto.MAX(klasor), naruto.seri, one_piece.MAX(klasor), one_piece.seri, bleach.MAX(klasor), bleach.seri FROM `naruto` INNER JOIN `one_piece` INNER JOIN `bleach ON` LIMIT 1'

Use a GROUP BY clause like

select id,series,max(folder) as max_folder
from table1
group by series

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM