Solved

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

Posted on 2002-05-20
1
165 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now