473,405 Members | 2,300 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,405 software developers and data experts.

Query within the same table

1
Please help me creatng a query
I've got 1 table called PRODUCT containing all my hardwareitems
Some hardwareitems belongs to another hardwareitem. For example a monitor belongs to a PC. There could be up to 3 levels.

I wants to create a query which results all my hardwareitems and the hardwareitems to which they belongs.

Example table PRODUCT
(the level-number (L1, L2 and L3) are only written down for more clearence)

productid parentid assetnumber description
500 00300 PC PD N419 3.0/1G/80Gb CAD (L1)
507 500 00180 Monitor Philips 17 inch LCD 170P6ES (L2)
700 00300 IBM SAN TS DS4000 (L1)
180 700 00120 IBM SAN Enclosure DS4000 EXP710 (L2)
200 700 00110 IBM SAN Enclosure DS4000 EXP710 (L2)
230 180 00140 IBM DISK Fibre 246.8GB/10K (L3)
225 200 00135 IBM DISK Fibre 246.8GB/10K (L3)

The query-result should looks like ....

00300 PC PD N419 3.0/1G/80Gb CAD
00180 -- Monitor Philips 17 inch LCD 170P6ES

00300 IBM SAN TS DS4000
00110 -- IBM SAN Enclosure DS4000 EXP710
00135 ---- IBM DISK Fibre 246.8GB/10K
00120 -- IBM SAN Enclosure DS4000 EXP710
00140 ---- IBM DISK Fibre 246.8GB/10K

THX

Kind Regard
RickZH
Sep 8 '07 #1
1 1288
Scott Price
1,384 Expert 1GB
You cannot create a one to many relationship within the same table, which is what you are trying to do.

You will have to create a separate table that contains the 'many' products, that is related to the table with the 'one' products.

Example: tblProducts, will contain PCX, tblComponents will contain MonitorX, CPUX, etc.

Regards,
Scott
Sep 8 '07 #2

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

Similar topics

1
by: Jim Geissman | last post by:
Help, please. I am trying to update a table with this structre: CREATE TABLE Queue (PropID int, EffDate smalldatetime, TxnAmt int) INSERT Queue (PropID) SELECT 1 INSERT Queue (PropID)...
3
by: John Ortt | last post by:
> I have a table of dates in ascending order but with varying intervals. I > would like to create a query to pull out the date (in field 1) and then pull > the date from the subsequent record...
4
by: C White | last post by:
Hi I am having problems with running a query that does the following there are 5 fields in a table that the query is based on, the first four are simple enough and all that happens is that the...
0
by: Jeff Boes | last post by:
I hope this helps someone else ... I had struggled some time ago with attempts to get a rank of values query to work, but then I gave up and set it aside. I had another reason to attack it, and in...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
6
by: sara | last post by:
I hope someone can help with this. Our director wants to have a report that will have the departments (Retail stores) across the top, stores down the side and the RANKING of the YTD dept sales...
5
by: Sam | last post by:
Hi, I have one table like : MyTable {field1, field2, startdate, enddate} I want to have the count of field1 between startdate and enddate, and the count of field2 where field2 = 1 between...
4
by: Doris | last post by:
It does not look like my message is posting....if this is a 2nd or 3rd message, please forgive me as I really don't know how this site works. I want to apologize ahead of time for being a novice...
18
by: cov | last post by:
I have a query where I'm attempting to pull data from 3 different tables using php and mysql. I had hoped to have a unique identifier to help ensure referential integrity but it appears that...
7
by: cov | last post by:
I have a php query where I'm attempting to pull data from 3 different tables between a php form and mysql db. I had hoped early on to use a unique identifier to help ensure referential integrity...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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,...
0
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...

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.