473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Query for finding relation between 2 fields

3
Hi All, I hope someone is able to help me with this.

I am having a table with partnumber(s) like shown here

ID (autonumber, primary key)
Partnumber (text)
Replacment (text)
Description (text)
Comment (text)
..... <Some other fields>.

Data look like this:
ID Partnumber Replacement Description Comment
x 5030331-001 Partx
x 5030332-001 5030332-002 Part1 from vendor 1 Obsolete
x 5030332-002 8063737-001 Part1 from vendor 1 Obsolete
x 5030333-001 Partx
x .....
x 8063737-001 Part1 from vendor2

There are a lot of Partnumbers which are obsolete (this partnumber has a replacement part). I am searching for a query where (with one parameter, = partnumber to look for), where i can see complete relation. So if I am searching for partnumber 8063737-001 I get same result as when I am searching for 5030332-001 or 5030332-002.

Result should be like this:
ID Partnumber Replacment Description Comment ...........
x 5030332-001 5030332-002 Part1 from vendor 1 Obsolete
x 5030332-002 8063737-001 Part1 from vendor 1 Obsolete
x 8063737-001 Part1 from vendor2


has anyone any idea how to create this kind of query?

Ludo
Nov 22 '09 #1
3 1367
Delerna
1,134 Expert 1GB
Maybe you should post your query also, because I can't clearly decipher what you are asking above.


Also, maybe you can explain this
I get same result as when I am searching for 5030332-001 or 5030332-002.
in a bit more detail because if
So if I am searching for partnumber 8063737-001
then I don't get why the result would look like

ID Partnumber Replacment Description Comment ...........
x 5030332-001 5030332-002 Part1 from vendor 1 Obsolete
x 5030332-002 8063737-001 Part1 from vendor 1 Obsolete
x 8063737-001 Part1 from vendor2


I would have thougt the result should look like

ID Partnumber Replacment Description Comment ...........
x 5030332-001 5030332-002 Part1 from vendor 1 Obsolete

when the parameter= 5030332-001



OR


ID Partnumber Replacment Description Comment ...........
x 5030332-002 8063737-001 Part1 from vendor 1 Obsolete

when the parameter= 5030332-002


or

ID Partnumber Replacment Description Comment ...........
x 8063737-001 Part1 from vendor2

when the parameter= 8063737-001
Nov 22 '09 #2
LudoS
3
Hi,

The from word was just as a text "part1 from vendor 1".
This was only an example, I have thousands of partnumber(s). Partnumbers are correlated to product-table. Most of the time a partnumber without a replacement part (replacement = empty). Sometimes we want to see the history of these partnumber(s). So for example when user is requesting this, I wnat to have the result like this:

partnumber, replacement, (other fields)
x1, x2, ....
x2, x3, ....
x3, x4, ....
x4, <empty>, ...

The number of rows (result) can 1 to ???

repeat
........
Select * from partTable where partnumber=@paramater or replacement=@paramater
......
until <everything has been found>

Something like this, it is not right but don't know how to express it more clearly.

<everything has been found>
1. part has no replacement AND [last row, like x4]
2. partnumber from 1st could not be found in replacement [first row, like x1]


In vba I think it could be quite easy routine, but i like to create some kind of query.
Nov 23 '09 #3
NeoPa
32,556 Expert Mod 16PB
Basically, you need to add your table (We'll refer to it as tblPartNo as you haven't told us what it is) once for each part in the first place, then again for each level of redirection you want to cover.

Each table would have a (LEFT JOIN) link from its [Replacement] field to the [PartNumber] field of the next copy of the table.

If you start from there it will soon become clear what you are dealing with and how to proceed from there.
Nov 23 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Robert Marshall | last post by:
Hi all, Hoping someone can help me with an issue I'm having. I'm using AccessXP to create a database of U.S. Census records. After keying the data in, I decided to run a query to create a...
11
by: deko | last post by:
If I release a new version of my mbd (in mde format) and users want to upgrade - how do they migrate their data? For example, if the original was released as data1.mde and then I release...
3
by: pw | last post by:
Hi, I am having a mental block trying to figure out how to code this. Two tables: "tblQuestions" (fields = quesnum, questype, question) "tblAnswers" (fields = clientnum, quesnum, questype,...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
10
by: Dixie | last post by:
I need to delete some relationships in code. How do I know what the names of those relationships are?
11
by: Bruce Lawrence | last post by:
Ok, I'm baffled... I'm making a query in access 97 between 2 tables. There is a field in both tables called "DWGNO". OPENORD has a record with a DWGNO of "00000012345" DIEDATA has a record...
5
by: themastertaylor | last post by:
I've got a system to manage various quotes for building materials for a number of sites. i want a query to produce a report that shows me who HASN'T quoted for which sites. basically so i can...
30
by: Vadim Tropashko | last post by:
Reposting with more clarification (as Jan asked). Suppose I have a BNFgrammar and a source text parsed into a tree. How would I query an identifier declaration? All the XQuery tutorials...
1
by: LudoS | last post by:
Hi All, I hope someone is able to help me with this. I am having a table with partnumber(s) like shown here (actually a access2003 database) ID (autonumber, primary key) Partnumber (text)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.