FOREIGN KEY - Cannot add or update a child row

Error

SQL query:

SHOW CREATE TABLE vid

MySQL said:

#1146 - Table 'news.vid' doesn't exist

that’s pretty clear, what are you not understanding? There’s no appeareance of any table called “vid” within a database called “news”. And i don’t see any table named “table1” - did you just copy the code without altering it to your specific case?

table1 is not there is was by mistake posted

i am getting same error for all them |vid|sid|title|titleimage|description|link|datetime|

please clear do i have to run this query in the main db or the section created in the db

and if form the main then its this

Table Create Table
video CREATE TABLE video (
vid int(11) NOT NULL AUTO_INCREMENT,
sid int(11) NOT NULL,
title varchar(50) NOT NULL,
titleimage varchar(50) NOT NULL,
description varchar(500) NOT NULL,
link varchar(50) NOT NULL,
datetime timestamp NOT NULL,
PRIMARY KEY (vid),
KEY sid (sid),
CONSTRAINT video_ibfk_1 FOREIGN KEY (sid) REFERENCES video (vid) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1

and what exactly do you expect for show TABLE to show you on a column name? And what did the documentation tell you about show table?

my error is this and need help to solve it whats the issue here only another section has no issue but this only

Problem with query Cannot add or update a child row: a foreign key constraint fails (news.video, CONSTRAINT video_ibfk_1 FOREIGN KEY (sid) REFERENCES video (vid) ON DELETE CASCADE ON UPDATE CASCADE)

could you please confirm, you are trying to get the sid column in the video table to be a foreign key to the vid column in the same table?

yes this is my table
vid sid title titleimage description link datetime

okay, i just tested this, and it works just fine

maybe you could delete your table and try creating it again

thanks all ready fixed few moments ago
thanks for the help

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.