Hi, My database table structure is: PK_ID, category,parentId I wanted to select parentId, PK_ID, category where PK_ID=9 and then category and PK_ID where parentId = PK_ID Please help! Thanks.
Your structure looks a little bit wired to me perhaps i am just a little bit confused. you normally don't make any tables just for one id. how is the complete structure ? One example table_parent parentId|name|prename|categorie_id <- this is the foreign key table_categorie categorie_id|categorieName if you want to combine both data with each other you need an inner join. like this select * from table_parent inner join table_categorie on table_categorie.categorie_id = table_parent.categorie_Id where categorie_Id = 9; so without your complete structur i can't help you. But with this example it should be possible for you to solve the problem.
Hi dizyn , can you tell me which is primary key so i can give you appropriate suggestion for your query . One more if you are using Server 2005 so go to query builder and write query... You will definitely get the answer..
It sounds like you have the relationship around the wrong way. That table would be a "validation" table and you put it's ID field into a "joining" table that also has the ID from the parent table, then you can get the information you want. To summarize, you usually need the second ID field in a table that has the "many" relationship, not the "one" relationship, that's how the data sharing works.