table #1:
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
UserID | int(11) | NO | PRI | NULL | auto_increment |
Password | varchar(20) | NO | |||
Username | varchar(25) | NO | |||
varchar(60) | NO |
table #2:
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
UserID | int(11) | NO | MUL | ||
PostID | int(11) | NO | PRI | NULL | auto_increment |
Title | varchar(50) | NO | |||
Summary | varchar(500) | NO |
Error:
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (
myapp/table2
, CONSTRAINTtable2_ibfk_1
FOREIGN KEY (UserID
) REFERENCEStable1
(UserID
))
What have I done wrong? I read http://www.w3schools.com/Sql/sql_foreignkey.asp and I don’t see what’s wrong.
Related Posts:
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- String concatenation in MySQL
- What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? [duplicate]
- MySQL server startup error ‘The server quit without updating PID file’
- How do I restore a dump file from mysqldump?
- Not unique table/alias
- Install mysql-python (Windows)
- SQL – Update multiple records in one query
- Create a new database with MySQL Workbench
- Disable ONLY_FULL_GROUP_BY
- Column ‘user_id’ in field list is ambiguous
- Database sharding vs partitioning
- 1052: Column ‘id’ in field list is ambiguous
- Escape string Python for MySQL
- 1052: Column ‘id’ in field list is ambiguous
- how to overcome ERROR 1045 (28000): Access denied for user ‘ODBC’@’localhost’ (using password: NO) permanently
- SQL ZOO List each continent and the name of the country that comes first alphabetically
- MySQL Error #1133 – Can’t find any matching row in the user table
- How can I prevent SQL injection in PHP?
- Best way to store an array in MySQL database?
- Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root
- ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘db’
- How to install Python MySQLdb module using pip?
- Access denied for user ‘root’@’localhost’ (using password: YES) after new installation on Ubuntu
- Dump all tables in CSV format using ‘mysqldump’
- How to check if mysql database exists
- #1062 – Duplicate entry for key ‘PRIMARY’
- How can I convert a string to a float in mysql?
- Is there a Profiler equivalent for MySql?
- How to do a batch insert in MySQL
- If variable equals value php [duplicate]
- MySQL: Cloning a MySQL database on the same MySql instance
- mysqldump data only
- PHP date() format when inserting into datetime in MySQL
- WordPress mysqli and PDO
- MySQL Replication Latency Issues in wp-admin pages
- Alternative to mysql_real_escape_string
- Increment value (value = value+1) of $wpdb->update
- How can I debug my database connection for unit testing?
- Same option_id=0 for 2 options in wp_options?
- How to let a user choose an authors and save it to the database?
- How to remove ‘GROUP BY’ from SQL query produced from get_posts?
- MySQL LIKE not working
- Importing MariaDB into Mysql in WordPress
- Is a MySQL DATETIME or TIMESTAMP value retrieved through $wpdb in UTC?
- How to get a Google maps SQL->XML->map marker tutorial to work in WordPress
- Update a WordPress post or page takes 60+ seconds
- Join new table with SQL query
- WordPress installation on valet php 8 (PHP Fatal error: Uncaught mysqli_sql_exception Table ‘wp_options’ doesn’t exist in wp-includes/wp-db.php:2056)
- MySQL crashed because of the large number of requests
- Why doesn’t this code add a table to my database?
- SQL database export-import
- add_post_meta does not respect the content
- Can Someone Help Me Fix This WordPress Missing Argument Error?
- How do I get create a custom table showing the hours remaining for all customers in one page from this transactions page?
- Uncaught Error: Call to undefined function mysql_connect() – WordPress installation
- SQL Database, repeated tables?
- Visual/Text Editor displays blank pages in WP-Admin- but HTML on client side displays correctly
- Code to remove authors with no posts connected to them
- SQL Query in WordPress – Getting Impossible WHERE error
- SQL syntax error when getting data for a url
- WordPress create database not working
- Import CSV to MySQL, with custom registration field information
- database optimization and server errors
- Setting up WordPress Locally on WAMP for a new site (with one already)
- Will reducing mysql permissions hinder WP function? [duplicate]
- Calling mysql_query() on another database, assumes WordPress using that database
- WordPress VIP realpath Alternative?
- querying user bookmarks from a large number of bookmarks
- Pull post name from value of a specific meta key
- PHP variables in mysql query
- Php Mysql Terms
- Export SQL query based on custom field?
- How to fix the amount of comments displayed for each post?
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- Lock wait timeout exceeded; try restarting transaction
- How to simulate web traffic to test performance of a website
- SQL query to change custom field in WordPress database
- SQL. Select category descendants
- MySQL Actibity without any active visitors via Google Analytics
- How to configure WordPress Database for CentOS 7
- Why should be SQL keywords, like CREATE TABLE and UPDATE, must be uppercase in WordPress?
- Why is local wordpress install calling live site executions?
- Add row to SQL array
- Display MySQL as part of a Page
- Migration of wordpress database from mariadb 10.0.20 to 5.5.50
- Use custom query if main search query returns zero results in wordpress
- WP Meta Query – mixed AND / OR query doesn’t work
- get_results() query not working only when entering strings
- Geographical proximity query using post_meta
- Second completely independent and disposable WordPress installation in subdirectory?
- get_results suddenly not working on a single table
- Internal error (500) on local & Fatal error on live when trying to access post type edit screen
- Query sql for truncate post_content in wp_posts table
- Foreach only outputs if id is 0
- Using queries in and i see 7000+queries?
- “Error 1064” when importing msql database after updating wordpress version to 4.2.1
- InnoDB: Error: log file ./ib_logfile0 is of different size
- Postgres equivalent to MySQL’s \G?
- How can I show mysql locks?