How to make an INNER JOIN bringing everything from two tables and one more "max" in a specific field?



  • Good people, to be more specific I have two tables,. table 01:

    inserir a descrição da imagem aqui

    ...and table 02:

    inserir a descrição da imagem aqui

    ...and I would like to make a "select" bringing all of these two tables, but where in the "points" field (table 02) has the largest number of points, how to do that?

    Ex.: Alex Bernardes, 20,00, 15,00, 35,00, 01/11/2017 and the points: 110.



  • SELECT tabela1.*, tabela2.pontos, tabela2.garcom_id FROM tabela1 JOIN tabela2 WHERE tabela2.garcom_id = tabela1.id
    

    So you make the join of the 2 tables, returning only the points and the garcom_id field (it is necessary to make comparison).




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2