我有3个表,其中3个表有3个相同的列名
但是第3列有第3列与第1列第2列不同。
我的需要将澄清给定的图像和查询...
//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
答案 0 :(得分:0)
试试这个
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
答案 1 :(得分:0)
这可能很有用。
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,0 as telugu, t.telugu_1 from tenthclass_marks as t