Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

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

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
star4
Asked:
star4
1 Solution
 
bobbit31Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now