Showing posts with label foreign. Show all posts
Showing posts with label foreign. Show all posts

Monday, March 26, 2012

problem regarding foreign key

i have 3 table which is merchant, merchantcategory and merchantitem.

merchantcategory's foreign key is refer to merchant_id, and merchantitem's foreign key is refer to merchantcategory_id.....

the problem is like this...

i would like to select all the available items from merchantitem, but i only have the information of merchant_id, so what method should i use to get these output ??

i am using the functions which generated by codesmith with wilson ORMapper method....

i really hope that someone will provide me the solution.....thanks

If I understand correctly, I think:

SELECT merchant.Name, merchantitem.someitem1, merchantitem.someitem2, merchantitem.someitem3
FROM (merchant INNER JOIN merchantcategory ON merchant.Merchant_ID = merchantcategory.merchant_id) INNER JOIN merchantitem ON merchantcategory.merchantcategory_id = merchantitem.merchantcategory_id;

should be pretty much what you need.

hth

|||

thanks fUNKYgIBBON

i know this method......but now i am using the functions which is generated by codesmith...

so i cannot use this method......

Friday, March 9, 2012

problem linking tables

i can 't add tables to an existing relationship. the identifier of each new table is already existant as foreign key in an existing table called 'etablissement' : when i insert the new table and create the link with table 'etablissement' each table become marked with '*' et when i save i get this message :
"
Error ODBC : [Microsoft][ODBC SQL Server Driver][SQL Server]Conflict between
instruction ALTER TABLE and the constraint COLUMN FOREIGN KEY
'FK_etablissement_delegation'. the conflit happened in database
'maintenance', table 'delegation', column 'id_dele'."

nb fields are identic and nonnulls.The table's field where you'd like to set a foreign key(table 'delegation', column 'id_dele') contains an ID that does not exist in the table's field where you'd like to set a PK.