473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WHERE

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
2 1034
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
3574
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
3
21978
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
3
2267
by: Xiangliang Meng | last post by:
Hi, all. In 1998, I graduated from Computer Science Dept. in a university in China. Since then, I've been using C Language for almost 6 years. Although I'm using C++ in my current job, I'm also...
7
3030
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
5
2386
by: comp.lang.php | last post by:
if ($willLimitByDB) $sql = preg_replace('/#(+)#/i', '$$1', $sql); This does not give me the results I want, instead of the value of $where in $sql, I literally get '$where' instead. How do I...
5
5485
by: John | last post by:
I just cannot manage to perform a SELECT query with NULL parameter... My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB null value). TCATEGORYID and TCATEGORYPARENTID...
0
80494
NeoPa
by: NeoPa | last post by:
Background Whenever code is used there must be a way to differentiate the actual code (which should be interpreted directly) with literal strings which should be interpreted as data. Numbers don't...
1
2754
by: not_a_commie | last post by:
I was hoping for increased functionality with the where clause in C# 3.0. Using the new keyword 'var' would really allow us to take nice advantage of these. Specifically: 1. I want to limit it...
9
19113
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
8
3462
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.