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

153
Views
Cómo agregar columnas y valores adicionales a una consulta MySQL INSERTAR SELECCIÓN

Hola tengo 2 columnas tbl_feestudent y tbl_feeschool y estas son sus columnas

feestudent_id, student_id, schoolyear_id, gradelevel_id, feetype_id y feestudent_amount.

feeschool_id, schoolyear_id, gradelevel_id, feetype_id y feeschool_amount.

Estoy usando una consulta MySQL de INSERT SELECT donde todos los elementos seleccionados en tbl_feeschool se insertarán en tbl_feestudent

Sin embargo, tbl_feestudent tiene una columna adicional que es student_id

¿Cómo insertaría un valor de student_id en todos los valores insertados provenientes de tbl_feeschool?

Digamos que el valor de student_id es 40 , a la tabla le gustaría esto.

ingrese la descripción de la imagen aquí

A partir de ahora, esta es mi consulta de INSERT SELECT con WHERE schoolyear_id = 4 y gradelevel_id = 1.

 INSERT INTO tbl_feestudent (schoolyear_id, gradelevel_id, feetype_id, feestudent_amount) SELECT schoolyear_id, gradelevel_id, feetype_id, feeschool_amount FROM tbl_feeschool WHERE schoolyear_id = 4 AND gradelevel_id = 1
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Agregue id a su consulta de selección suponga que su student_id es 40 entonces

 INSERT INTO tbl_feestudent (student_id,schoolyear_id, gradelevel_id, feetype_id, feestudent_amount) SELECT 40,schoolyear_id, gradelevel_id, feetype_id, feeschool_amount FROM tbl_feeschool WHERE schoolyear_id = 4 AND gradelevel_id = 1
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!