使用2个表插入值,使用sql server将列更新为主状态 [英] insert value using 2 tables to update a column as main status using sql server

查看:88
本文介绍了使用2个表插入值,使用sql server将列更新为主状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..你能帮助我如何创建一个具有这种逻辑的源,其中我需要比较第一个表中的某个值,其中第二个数据将在其列上插入指定的字符串值,并且可以在其中进行更改迟到的状态



第一张表

Hi everyone .. can you help me how to create a source having this logic wherein i need to compare a certain value in the first table in which the second data will insert the assigned string value on its column and can be change within the late status

1st table

id   |   name    |  status |  age  |
1    |   danny   |  single |  20   |
2    |  marlon   | married |  38   |
3    |   paul    |  single |  25   |





第二张表



2nd table

id   |  name      |  educational level   |  status  |  
1    |  danny     |   undergraduate      |  single  |
2    | marlon     |  college graduate    |  married |
3    | paul       |    college graduate  |  married |





其中最终输出将是



in which the final output will be

id  | name   | status |
1   | danny  | single |
2   | marlon | married|
3   | paul   | married|





i希望你理解这个场景..感谢您提前帮助..



i hope you understand this scenario.. thanks for advance for you help..

推荐答案

试试这个:

Try this:
SELECT t1.id, t1.[name], t2.status
FROM FirstTable AS t1 INNER JOIN SecondTable AS t2 ON t1.id = t2.id


这篇关于使用2个表插入值,使用sql server将列更新为主状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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