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

198
Visualizações
MYSQL XDEVAPI Multiple OR (II) Request

I'm using the XDEVAPI and trying to use the or(||) statement in javascript, but it seems to break after 1 or/(||) statements, I have 5 separate statuses I'm trying to pull from the DB:

.select(['customer_name',
         'account_status',
                  ])
         .where('customer_name like :customer_name && account_status like :account_status || account_status like :account_status || account_status like :account_status')
         .bind('customer_name', customer_name)
         .bind('account_status', 'Some_Status_1')
         .bind('account_status','Some_Status_2')
         .bind('account_status', 'Some_Status_3')
         .execute()

Can I use REGEXP 'Some_Status_1'|Some_Status_2'| etc?

If so what would the syntax be?

Or is there another method that I am missing.

Thanks for any help you can offer.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I don't think the issue is related to OR per se but to the fact that you are using duplicate placeholders. CRUD style APIs use named parameters, as described here. By calling bind('account_status', 'something') multiple times, you are simply replacing the last value of the account_status placeholder.

To do what you want (I think), you need to use different placeholder names. For instance:

.select(['customer_name', 'account_status'])
  .where('customer_name like :customer_name && account_status like :account_status1 || account_status like :account_status2 || account_status like :account_status3')
  .bind('customer_name', customer_name)
  .bind('account_status1', 'Some_Status_1')
  .bind('account_status2', 'Some_Status_2')
  .bind('account_status3', 'Some_Status_3')
  .execute()

Disclaimer: I'm the lead developer of the MySQL X DevAPI connector for Node.js

about 4 years ago · Juan Pablo Isaza 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