how to pass a null value to a foreign key field?

前端 未结 3 1766
庸人自扰
庸人自扰 2020-12-10 10:32

I have 2 tables:

university:

university_id(p.k) | university_name

and user:

uid | name |          


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 11:02

    I was using MySQL InnoDB and even allowing NULL in the FK column and using NULL as default I was getting an error. So I used the SET syntax:

    INSERT INTO (table) SET value1=X...
    

    And I just don't set the FK column.

提交回复
热议问题