Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!