php constraint violation Error 1452

后端 未结 1 1161
慢半拍i
慢半拍i 2021-01-29 12:32

Good morning, i have a big problem with this sql error when i,m trying to insert a event in my database with this pdo:


SQL:

$subsquery1 = \"SELECT cat_id         


        
相关标签:
1条回答
  • 2021-01-29 12:53

    Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (datenbank.events, CONSTRAINTevents_ibfk_1FOREIGN KEY (event_cat) REFERENCEScategories(cat_id)

    You are performing an insert to table events with a value being placed in column event_cat.

    That value does not already exist in table categories in the column cat_id.

    And you said it must. So the db engine says it won't do it. It is faithfully obeying your orders.

    0 讨论(0)
提交回复
热议问题