stored procedures - Join two tables and return data from both -
i have 3 tables as.
**table 1** **table 2** **table 3** lot_no(pk) lot_no(pk/fk) lot_no(fk) name job type material phone printing qty trim
look @ sample data
**table 1** **table 2** **table 3** 1 mian sultan xyz 1 reverse 50,000pcs 1 pvc 20 2 mian usman xyz 2 new 10,000pcs 1 ink 30 2 milky 25 2 ink 35
i want show data table 2 & table 3 on basis of lot_no. example user enter lot_no=1 result should displayed as
1 reverse 50,000pcs 1 pvc 20 1 ink 30
if user enter lot_no=2
2 new 10,000pcs 2 milky 25 2 ink 35
my query follows.... @lotnum int (variable declaration in stored procedure)
select table2.lot_no, table2.job_type, table2.printing qty, table3.material, table3.trim table2 inner join table3 on (table2.lot_no=table3.lot_no) table2.lot_no=@lotnum , table3.lot_no=@lotnum;
it shows me correct result when use in crystal report shows only..... when lot_no=1
1 reverse 50,000pcs 1 pvc 20
it don't show
1 ink 30
similar case when lot_no=2. please guide me thanks.
Comments
Post a Comment