我有3个表,其中3个表有3个相同的列名
但第三个表的第三列与第一个第二个表的列不同..
我的需要将澄清给定的图像和查询...
//this the query I'm using but not I wanted
select l.admission_number,l.student_class ,l.student_name ,l.telugu from lkg_to_seventh_marks as l
union all
select e.admission_number ,e.student_class ,e.student_name ,e.telugu from eighth_to_ninth_marks as e
union all
select t.admission_number ,t.student_class ,t.student_name,t.telugu_1 from tenthclass_marks as t
最佳答案
尝试这样
select l.admission_number,l.student_class ,l.student_name,l.telugu,NULL as telugu_1
from lkg_to_seventh_marks as l
union all
select e.admission_number ,e.student_class ,e.student_name ,e.telugu ,NULL as telungu_1
from eighth_to_ninth_marks as e
union all
select t.admission_number ,t.student_class ,t.student_name,NULL as telugu, t.telugu_1
from tenthclass_marks as t
我想你想要这个查询
select l.admission_number,l.student_class ,l.student_name,cast(l.telugu as char(50))
,'NULL' as telugu_1 from lkg_to_seventh_marks as l
union all
select e.admission_number ,e.student_class ,e.student_name ,cast(e.telugu as char(50))
,'NULL'as telungu_1
from eighth_to_ninth_marks as e
union all
select t.admission_number ,t.student_class ,t.student_name,'NULL'as telugu,
cast(t.telugu_1 as char(50)) as telungu_1
rom tenthclass_marks as t
关于mysql - 如何编写一个查询,其中包含3个表相同的列,并执行其中一个不同的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26421788/