Select between 2 tables

Discussion in 'MySQL' started by danielldf, May 26, 2016.

  1. #1
    database:
    agencia (nome_agencia, cidade_agencia, fundos)
    cliente (nome_cliente, rua_cliente, cidade_cliente)
    conta (nome_agencia, numero_conta, saldo)
    emprestimo (nome_agencia, numero_emprestimo,total)
    depositante (nome_cliente, numero_conta)
    devedor (nome_cliente, numero_emprestimo)

    SELECT rua_cliente, numero_conta FROM cliente, conta WHERE rua_cliente LIKE '%Rua a%', conta.numero_conta;

    This select would show results from column "rua_cliente" having "Rua a" and its "numero_conta" related results?
     
    danielldf, May 26, 2016 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,832
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I'm not quite sure what you are after - is it just that you need to know how many contact records there are for each client
     
    sarahk, May 26, 2016 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    Unless the cliente and conta tables themselves have a relationship (basically a column that link them together, either directly or through other tables), there isn't a good way to do this.
     
    jestep, Jun 2, 2016 IP