请帮助以下简单查询 [英] Please help with the following simple query

查看:77
本文介绍了请帮助以下简单查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下表格结构:
test [emp_name,emp_id,dept,mgr_id,sal] .
现在,我要显示所有雇员的emp名称,部门名称以及他们的经理名称.
我写了以下查询:
从测试t1中选择emp_name,emp_id,mgr_id,
emp_name作为测试t2中的manager_name,其中
t1.mgr_id = t2.emp_id

但出现以下错误:
第156条消息,状态15,状态1,第2行
关键字"from"附近的语法不正确.

Hi I have the following table struture:
test[emp_name,emp_id,dept,mgr_id,sal].
Now I want to display all the employees emp name,dept along with their manager name.
I have written the following query:
select emp_name,emp_id,mgr_id from test t1,
emp_name as manager_name from test t2 where
t1.mgr_id=t2.emp_id

but it''s giving the following error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword ''from''.

推荐答案

Try

Try

select t1.emp_name,t1.emp_id,t1,mgr_id,
t2.emp_name as manager_name from testt1, test t2 where
t1.mgr_id=t2.emp_id


这篇关于请帮助以下简单查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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