Solved

getting 4 different colomns from 2 diff tables (need SQL statement)

Posted on 2002-05-20
1
198 Views
Last Modified: 2010-03-31
suppose i have two tables :
table1 contains 5 colomns ;
empno     leavecode  fromdate    todate      grade
1000       1         12/4/2001   12/5/2001    1/2
1001       1         5/4/2001     5/6/2001    3/2
1000       2         12/5/1999    12/9/1999   1/2

table2:
grade     leavetype   days   leavecode
1/1         annual     50       1
1/2         annual     40       1
1/2         emergency  5       2


i want to read empno from a form and according to his/her
number and grade i will display leavetype ,days ,fromdate and todate for that specific number.

i tried to do like that :
select empno,leavecode,fromdate,todate,grade,leavetype,days,leavecode from leaves,masterleaves
where empno like empno and from date like '%/%/year'and grade in
(select grade from masterleaves
and leavecode in
(select leavecode from masterleaves));

0
Comment
Question by:star4
1 Comment
 
LVL 18

Accepted Solution

by:
bobbit31 earned 60 total points
ID: 7022310
how bout:

"select T1.fromdate, T1.todate, T2.leavetype, T2.days from table1 T1, table2 T2 WHERE t1.empno = " + empno + " and T1.fromdate like '%/%/" + year + "' and T1.grade = T2.grade and T1.leavecode = T2.leavecode"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question