473,394 Members | 1,878 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,394 software developers and data experts.

Foreign Key in Mysql

147 100+
Hi,

i have empty rows in my table.While trying inserting my records.It shows me the following errors:


ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint f
ails (`test`.`stuprmst`, CONSTRAINT `stuprmst_ibfk_1` FOREIGN KEY (`rollno`) REFERENCES `stuprmst` (`rollno`))
Apr 15 '10 #1
2 2200
Dheeraj Joshi
1,123 Expert 1GB
is roll number a foreign key? In that case you must add the roll number in the parent table then try to add it in child table.

Regards
Dheeraj Joshi
Apr 16 '10 #2
santhanalakshmi
147 100+
i have all my records in the parent table.But why i cant able to insert the same primary key value in the foreign key table...



thanks
Apr 29 '10 #3

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

Similar topics

0
by: dcp | last post by:
I just installed the 4.1.0-alpha-max-nt version of MySql and have just started playing around with it. My first test was to try to create a couple of tables, one with a foreign key constraint. ...
0
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get...
0
by: b b | last post by:
I am using MYSQL 4. I understand that it allows for foreign keys. Could someone show me an example of how to declare a foriegn key. I tried a combination of statements but I always got a syntax...
5
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
0
by: Phil | last post by:
I am using MySQL 4.1.1-1. When I add a "named" foreign key constraint alter table sb_query_nm_sub_tp add constraint f1sbquerynmsubtp foreign key (query_nm) references sb_query_class...
2
by: Jeff Silverman | last post by:
I am working on my first database and I think I want to build a table with a foreign key in it. The O'Reilly book on MySQL says that MySQL does not support foreign keys, but it still talks about...
3
by: heroe | last post by:
Hello *, i write you with an urgent problem. I would like to create forign keys to datetime field, but it doesn't seem to work. I get Can't create table '.\sampleDB\student_module.frm' (errno:...
2
by: Ian Davies | last post by:
I have created a database with about 17 tables. I have been creating foreign keys some of which have worked but when creating others I get the message below ************************* 1005...
2
by: kal stevens | last post by:
I have been trying to write a database schema in mysql, and I cant figure this out. Here is a database schema DROP DATABASE IF EXISTS d; CREATE DATABASE d;
5
by: coosa | last post by:
Dear all, I'm new under mysql and have installed mysql5.0.24a community edition for win32. I have tried to implement a foreign key for this following sample scenario: CREATE TABLE student (...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.