November 19, 2022 at 10:22 pm
Hello, my name is Di, and its the second time I wrote a topic for this forum, I am having some issues for writing a query where I need to create a foreign key, I already search on some places at internet, but none of then helped me, can you guys help me?
November 19, 2022 at 11:45 pm
The error seems to indicate that the "idCategoria" column doesn't exist in one of the two tables. Check each of the two tables to make sure that the column does actually exist in both tables. I strongly suspect that the column you're looking for in the Categoria table is actually just "ID" (a lot of people make such a choice in their designs).
--Jeff Moden
Change is inevitable... Change for the better is not.
November 20, 2022 at 1:43 am
I made idCategoria only on table categoria, I was gonna make an Alter Table on usuario for creating the foreign key, it means then that I need to create idCategoria on table usuario before trying to set it as a foreign key ?
November 20, 2022 at 11:03 am
I made idCategoria only on table categoria, I was gonna make an Alter Table on usuario for creating the foreign key, it means then that I need to create idCategoria on table usuario before trying to set it as a foreign key ?
Yes
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
November 20, 2022 at 11:04 am
--Deleted. Once again, the site created two versions of my post
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
November 20, 2022 at 5:06 pm
I made idCategoria only on table categoria, I was gonna make an Alter Table on usuario for creating the foreign key, it means then that I need to create idCategoria on table usuario before trying to set it as a foreign key ?
Ok.. then I'm confused. Why would you knowingly try to use a column name that you know doesn't exist in a Foreign Key?
At this point, I have to ask... what are you trying to accomplish with the Foreign Key?
--Jeff Moden
Change is inevitable... Change for the better is not.
November 21, 2022 at 10:22 pm
I made idCategoria only on table categoria, I was gonna make an Alter Table on usuario for creating the foreign key, it means then that I need to create idCategoria on table usuario before trying to set it as a foreign key ?
I've never tried it without having the columns already setup but, to the best of my knowledge, FK constraints aren't defer-able.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply