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

542
Visualizações
How to query id not in condition with another table typeorm

Here is the query

SELECT * from tableA WHERE tableA.id NOT IN (SELECT tableB.a_id FROM tableB);

Same query how to write using TypeORM typescript? Below is code, I tried which is not working

this.createQueryBuilder('tableA')
.where(`tableA.id != :id`, { id })
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

const tableBqry = tableBRepository
       .createQueryBuilder('tableB')
       .select("tableb_id");

const tableAqry = tableARepository
       .createQueryBuilder('tableA')
       .where("tableA.id NOT IN (" + tableBqry.getSql() + ")");

const results = await tableAqry.getMany();

This method will work fine for the above-mentioned problem.

over 4 years ago · Santiago Trujillo Relatório

0

You can select IDs from tableB first, and then use the IDs you've got (I assume that they are mapped and stored in var ids: string[]) to make a query for tableA.

this.createQueryBuilder('tableA')
  .where(`tableA.id <> ALL(:ids)`, { ids })
over 4 years ago · Santiago Trujillo Relatório
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