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

154
Visualizações
How to Add Additional Column and Value to a MySQL Query INSERT SELECT

Hi I have 2 columns tbl_feestudent and tbl_feeschool and this is their columns

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

feeschool_id, schoolyear_id, gradelevel_id, feetype_id, and feeschool_amount.

I'm using a MySQL Query of INSERT SELECT where all the items that selected in tbl_feeschool will be inserted in tbl_feestudent

tbl_feestudent however has additional column which is student_id

How would I insert a value of student_id to all inserted values coming from tbl_feeschool

Let's just say the value of student_id is 40, the table would like like this.

enter image description here

As of now this is my query of INSERT SELECT with WHERE schoolyear_id = 4 and 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 Respostas
Responde à pergunta

0

Add id to your select query suppose your student_id is 40 then

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 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