Hello,

I have 2 datatable, first table for customers personal information and second table for customers areas of interest. this two tables have same ID for same customers.

So, when i want to check my some group of customers(like who intrests on sports stuffs) i need filter my first table according to my second table.

is there any easy way to do it?

thanks for your helps :)

yes you can join then or use nested select statements ,like this

Customers

custid
custname

Interest

interestid
custid
interestname

now you have to get all the customers who have interest in football , you can do like this .

select c.custid,c.custname ,i.interestname
from customers c
inner join interest i on i.custid = c.custid
where i.interestname = 'football'

and you can do like this also but this is not i recommend for you.

select c.custid,c.custname ,
            (select i.interestname from interest i where i.custid = c.custid and
             i.interestname = 'football') as InterestName
from customers c

the above query is faster then this.
tip: always try to avoid nested select statements in your query as much as possible. nested select statement slowdown your query.

Regards

Thank you so much it works greats. Thanks Again :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.