Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
SQL filter related name using javascript

What I did so far is I created a query to get all Authors, and I created a query for getting all published book by authors, my problem is that I cant filter what author published book on transaction. What i want is to count all author published book on transaction

This is my code

const getAuthors = async ()=>{
    return new Promise((resolve, reject)=>{
        var author = (`SELECT id, name FROM Author`, 1000, data=>{
            let obj = { authorsId: [] }
            for(let x = 0; x < data.length; x++){
                obj.authorsId.push(data[x][0]);
            }
            console.log(obj)
            return resolve(obj);
        })
    })
}

result of console.log(obj)

{
    "authorsId": [
        1,
        2,
        3,
        4
    ]
}

/

const getAuthorPublished = async ()=>{
  const authorsId = await getAuthors()
  return new Promise((resolve, reject)=>{
        var bookpublished = (`SELECT exp_fAuthor, rAuthors, exp_fAuthor_Published_Book FROM KTMS_Transaction`, 1000, data=>{
          let arrAuthorPublished = { authors: [], authorIds: [], counts: [] }
            for(let x = 0; x < data.length; x++){
                arrAuthorPublished.authors.push(data[x][0]);
                arrAuthorPublished.authorIds.push(data[x][1]);
                arrAuthorPublished.counts.push(data[x][2]);
            }
          console.log("arrAuthorPublished: ", arrAuthorPublished)
            return resolve(arrAuthorPublished);
        })
    })
}

//result of console.log(arrAuthorPublished)

{
    "authors": [
        "Claire",
        "Claire",
        "Yuno",
        "Claire"
    ],
    "authorIds": [
        440944522,
        440944522,
        440930072,
        440944522
    ],
    "counts": [
        1,
        1,
        1,
        1
    ]
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda