I have a table (employees) like this

ID Name Group Email

1          Bob Buckland       Marketing     b@example.com

2          George Alaz     Engineering   g@example.com

3          Tom Grady       Marketing     t@example.com

4          Mary Jane       Engineering   m@example.com

Im going to use this in a email form. First a combobox should load all the groups possible. This means it should load 2 groups, Marketing and Engineering

Groups is easy I believe:

select distinct Group from employees;

After selecting that, I should load all the names that are in that group.

Im not sure how to do names:

select Name from employees where=?

The "where" condition is what Im not sure about.

And after, how do I get the email I selected?


Recommended Answers

SELECT name, email FROM employees WHERE group = '<your_selected_group>'
Jump to Post

All 2 Replies

SELECT name, email FROM employees WHERE group = '<your_selected_group>'
commented: Good starting point +7

select distinct Group from employees;


select Name from employees where Group='Marketing'

Bob Buckland
Tom Grady*

select Email from employees where Group='Marketing' and Name='Tom Grady'


OK got it. Sorry, it was a simply query but It wasnt coming to my head.

Be a part of the DaniWeb community

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