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

115
Views
Conservar el orden de los resultados con WHERE IN con jOOQ

El problema ya se ha descrito en detalle en ORDEN POR la lista de valores IN ,

pero para repetir: quiero seleccionar elementos con ID 1,3,2,4 en ese orden específico.

Mi fragmento de jOOQ:

 var results = create.select().from(ITEM).where(ITEM.ID.in(1,3,2,4)).fetchInto(Item.class);

La lista de results resultante tendrá elementos en orden de 1,2,3,4. ¿Cómo puedo conservar el orden de los artículos con jOOQ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar Field.sortAsc() para esto:

 create.select() .from(ITEM) .where(ITEM.ID.in(1, 3, 2, 4)) .orderBy(ITEM.ID.sortAsc(1, 3, 2, 4)) .fetchInto(Item.class);

O, por supuesto, para evitar repetir la lista, utilice una variable local:

 Integer[] ids = { 1, 3, 2, 4 }; create.select() .from(ITEM) .where(ITEM.ID.in(ids)) .orderBy(ITEM.ID.sortAsc(ids)) .fetchInto(Item.class);

Consulte también este artículo sobre orden indirecto aquí .

over 4 years ago · Santiago Trujillo Report
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!