Join two tables

vks.gautam1

Well-known member
Joined
Oct 10, 2008
Messages
78
Location
Chandigarh, India
Programming Experience
Beginner
Select jal.* from jal inner join ussd_master on jal.mob_no=ussd_master.mob_no where ussd_master.act_date> #10/1/2008 #;


Here i got result where mobile numbers which are activated after 10/1/2008 (mm,dd,yyyy) .

How can i write a query where i get number which are in this given result.

One query work for the both results
 
Last edited:
If your data is in a datatable you can access the Table.Rows.Count to get the number of records returned.

If you're using a datareader you're going to need to use 2 queries and use the DataReader's ReadNext method.

VB.NET:
SELECT jal.* FROM jal ... #10/1/2008 #; SELECT @@ROWCOUNT
 
query

This is data of Mobile numbers.

First Table
Packet No. MobNo. ActvDate
DC-A0167 9915464942 09/30/2008
DC-A0167 9915466215 10/4/2008
DC-A0167 9779971722 11/6/2008
DC-A0167 9915982867 11/7/2008
DC-A0164 9815982980 12/5/2008
DC-A0167 9915462353 12/5/2008
DC-A0167 9915461587 12/5/2008



second table

MobNo. ActvDate
9915464942 11/30/2008
9915464942 05/30/2007

9915466215 12/4/2008
9779971722 12/6/2008
9915982867 12/7/2008
9815982980 12/5/2008
9915462353 12/5/2008
9915461587 12/5/2008

Some of the nos are doubled in table in database like in color

Here Common Field is MobNo
i want to retrieve data which is older than Oct month. Here if i make a query it gives me same MobNo twise(color nos).

select * from table1,table2 where ActDate<#10/1/2008#
 
select * from table1 t1 INNER JOIN table2 t2 ON t1.MobNo = t2.MobNo where ActDate<#10/1/2008#
 
Duplicate values

it is giving duplicate values.

if i use distinct . that is not working .

Packet No. MobNo. ActvDate
DC-A0167 9915464942 09/30/2008
OC-A0167 9915464942 06/30/2008
 

Latest posts

Back
Top