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

209
Views
Combinando 3 Tablas con Inner Join
<?php foreach ($category_features as $category_feature):?> <?php if( $category_feature['form_type'] == 'text' ){?> <div class="six wide field"> <label><?php echo $category_feature['feauture'];?></label> <input type="text" name="name-<?php echo $category_feature['id']?>"> </div> <?php } ?> <?php if( $category_feature['form_type'] == 'select' ){?> <div class="six wide field"> <label><?php echo $category_feature['feauture'];?></label> <select name="name-<?php echo $category_feature['id']?>"> <option value="">Choose</option> <?php foreach ($feauture_values as $feauture_value):?> <!-- how can i get the features' values --> <?php endforeach;?> </select> </div> <?php } ?> <?php endforeach;?>

Como puede ver, obtengo las características de la categoría de una tabla y un bucle. Y luego una característica tal vez un cuadro de selección para que las opciones estén en otra tabla. Para cada función que es un cuadro de selección, necesito obtener los valores de la función, lo que significa opciones. ¿Cómo puedo crear un SQL para esto?

**características

id | feature | form_type

**category_features

id | feature_id | category_id

**valores_de_características

id | feature_value | feature_id

Mis mesas son así. De acuerdo con category_id, obtengo las características. Y también quiero obtener opciones si form_type es selectbox.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Creo que necesita dos pasos para obtener la estructura de datos que desea.

primero, usando el SQL como este

 select f.from_type, f.feature, fv.feature_id, fv.feature_value from features as f inner join category_features as cf on f.id = cf.feature_id right join feature_values as fv;

y luego agregue el conjunto de registros, tal vez como el siguiente código

 $result = []; array_map(function (item) use (&$result) { // do some aggregate operations }, $records);

es difícil obtener el resultado correcto a la vez

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!