Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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…

790 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