我应该使用什么SQL查询? [英] What SQL Query should I Use?

查看:68
本文介绍了我应该使用什么SQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友

我正在使用Windows应用程序.我已经在MS Access文件中制作了两个表.第一个表(tblEmployees)具有Employees的所有详细信息.第二个表(tblDesig)有两列,第一列是Designation,第二列是ID.现在,我有将近50个名称,并且为每个名称指定了唯一的ID.
例如

名称-------- ID
经理------------ 1
助手---------- 2
会计师--------- 3
等等.

我在tblEmployees中也有一个指定字段.我将ID放在了Tempmployees的Designation列中,而不是实际的Designation中.
现在,我已经在表单中创建了一个Datagridview,并在Datagridview中创建了4列(名称,名称,薪水,地址)
我想用来自tblemployee的那些薪水超过500的员工来填充datagridview.到目前为止,所有事情都是对的.但是问题是我希望datagridview的指定字段应该填充实际名称(它是根据ID从tblDesig获取的),而不是ID.

那么,我该怎么做呢?我应该在这里使用什么SQL查询?
有人能帮我吗?等待答复.

Dear Friends

I am working on a Windows Application. I have made two tables in MS Access file. The first table (tblEmployees) has all the details of Employees. and the second table (tblDesig) has two columns, the first is the Designation and Second is ID. Now, I have almost more than 50 designations and I have given a unique ID to each designation.
For example

Designation--------ID
Manager------------1
Assistant----------2
Accountant---------3
and so on.

I have also a designation field in tblEmployees. I have put the ID in the Designation column of the tblemployees rather than the actual Designation.
Now I have made a Datagridview in my form and I have made 4 columns in Datagridview(Name,Designation,Salary,Address)
I want to fill the datagridview with the employees from tblemployee those have more than 500 salary. Until yet every thing is right. But the problem is that I want that the designation field of datagridview should filled with the Actual Designation (which it takes from the tblDesig on the basis of ID) not the ID.

So, How I can do that? What SQL Query should I Use here?
Can some one help me? Waiting for reply.

推荐答案

HI,您可以在表tblEmployees和tblDesig和 WHERE INNER JOIN 查询b>要求获得薪水为500的员工
HI you can use the SQL INNER JOIN query on the tables tblEmployees and tblDesig with WHERE clause to get the employee whose salray is 500


SELECT a.name, b.designation, a.salary, a.address
FROM tblEmployees a INNER JOIN tblDesig b
ON a.designation = b.id
WHERE a.salary > 500


这篇关于我应该使用什么SQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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