By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

WHERE

P: n/a
GTi
I have two tables

MEMBERS
Index
tableindex
Name
.....
PROJECT
Index
Name
I want to select data from PROJECT where a member is listed in MEMBERS
table.

Example:
John is member index 5.
He is a member in several PROJECTs

select * from PROJECT where (MEMBERS.index=5 and
MEMBERS.tableindex=PROJECT.index)

The result is a listing of all project John is a member of.

I'm nut sure I get this explaned correctly....
How can I do this query?

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi

When posting it is better to show proper DDL
http://www.aspfaq.com/etiquette.asp?id=5006 and example data (as insert
statements)

It sounds like you are looking for a JOIN between Project and Members

SELECT P.*
FROM PROJECTS P
JOIN MEMBERS M ON P.index = M.tableIndex
WHERE M.index=5

Also see the topics "Join Fundamentals" and "Using Joins" in books online.

John

"GTi" <bi**@gates.com> wrote in message news:J6Awd.3868$3N5.98@amstwist00...
I have two tables

MEMBERS
Index
tableindex
Name
....
PROJECT
Index
Name
I want to select data from PROJECT where a member is listed in MEMBERS
table.

Example:
John is member index 5.
He is a member in several PROJECTs

select * from PROJECT where (MEMBERS.index=5 and
MEMBERS.tableindex=PROJECT.index)

The result is a listing of all project John is a member of.

I'm nut sure I get this explaned correctly....
How can I do this query?

Jul 23 '05 #2

P: n/a
GTi
"John Bell" <jb************@hotmail.com> skrev i melding
news:41***********************@news.easynet.co.uk. ..
Hi

When posting it is better to show proper DDL
http://www.aspfaq.com/etiquette.asp?id=5006 and example data (as insert
statements)

It sounds like you are looking for a JOIN between Project and Members

SELECT P.*
FROM PROJECTS P
JOIN MEMBERS M ON P.index = M.tableIndex
WHERE M.index=5

Also see the topics "Join Fundamentals" and "Using Joins" in books online.

John

"GTi" <bi**@gates.com> wrote in message
news:J6Awd.3868$3N5.98@amstwist00...
I have two tables

MEMBERS
Index
tableindex
Name
....
PROJECT
Index
Name
I want to select data from PROJECT where a member is listed in MEMBERS
table.

Example:
John is member index 5.
He is a member in several PROJECTs

select * from PROJECT where (MEMBERS.index=5 and
MEMBERS.tableindex=PROJECT.index)

The result is a listing of all project John is a member of.

I'm nut sure I get this explaned correctly....
How can I do this query?



I found a similar function:
from http://www.w3schools.com/sql/sql_join.asp
I think it will give me the result I want...
SELECT Employees.Name
FROM Employees, Orders
WHERE Employees.Employee_ID=Orders.Employee_ID
AND Orders.Product='Printer'Thanks for pointing me to JOIN
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.