I have two tables:

tb1:
Name Email Location
-----------------------------------
user1 email1 address1
user2 email2 address2
user3 email3 address3
-----------------------------------

tb2:
Group Email
-----------------------------------
group1 email1,email2
group2 email4
group3 email5,email6
-----------------------------------

Now I want to join these two tables, to display the usernames who are listed in table 2, with keyword "email", so the result of above example will print:
----------------
user1, user2
----------------

I tried to use statement like:

SELECT a.name FROM tb1 a, tb2 b WHERE a.email IN b.email

but it doesn't work, anyone can advise me? thanks in advance.

try this:

SELECT tb1.name FROM tb1 INNER JOIN tb2 ON tb1.email = tb2.email

Let me know if that works for you

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.