Solved

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

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

803 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