根据rollno列将tb1中的2列连接到表tb2 [英] join of 2columns from tb1 to table tb2 according rollno column

查看:54
本文介绍了根据rollno列将tb1中的2列连接到表tb2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨frnds,

我在tb1中有2个表,它有很多列我想要选择年份,批处理并希望在tb2中加入表中的rollno。年份和批次应该根据tb2中的rollno匹配,就像已经在tb1 plz帮助我试过这个但是它不起作用

hi frnds,
i have 2 tables in tb1 it has many columns on that i want to select year,batch and want to join on tb2 in both the table has rollno. year and batch should match according to the rollno in tb2 like already in tb1 plz help i had tried this but its not working

select year, batch from tb1 left join tb2 on tb1.rollno = tb2.rollno;

推荐答案

你应该使用SQL INNER JOIN来返回满足连接条件的多个表中的所有行。



试试这个:



You should use SQL INNER JOIN that returns all rows from multiple tables where the join condition is met.

try this:

SELECT year, batch FROM tb1 INNER JOIN tb2 ON tb1.rollno=tb2.rollno


这篇关于根据rollno列将tb1中的2列连接到表tb2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆