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

130
Views
MySQL obtiene el título de parentid con dos tablas

Voy a tratar de explicar tanto como sea posible. aqui esta mi consulta..

 SELECT * FROM mm_star_ratings s JOIN mm_posts p ON s.post_id = p.postid WHERE p.type='B' ORDER BY s.rating DESC LIMIT 5

type='B' es la publicación principal y type='C' es la respuesta a esa publicación. Hay una columna parentid en mm_posts para establecer la identificación de la publicación principal (B) para C ¿Quiero obtener el title de mm_posts si type='C' está ahí de todos modos?

El desafío para mí es hacer que funcione con mi tabla de calificación donde post_id está configurado para B y C

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar la siguiente consulta,

 SELECT s.*,p.*, IF(p.type='C',pp.title,p.title) as title FROM mm_star_ratings s JOIN mm_posts p ON s.post_id = p.postid Left Join mm_posts pp on pp.postid=p.parent_id ORDER BY s.rating DESC LIMIT 5
about 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!