sql - 使用 UNIQUE 约束时如何插入不同的列
问题描述
我有这张桌子:
car-model 和 motor-model 都有独特的约束。
我尝试首先插入我所有的汽车模型。所以
Car-model
Volkwgen
Tesla
然后我想添加电机模型
Motor-model
PX
GX
但由于独特的约束,我得到 [Null] 值
即使没有唯一约束,我也会得到 [Null] 值。
解决方案
这是你想要做的吗?
insert into car_models (car_model, motor_model)
values ('Volkswagen', 'PX'),
('Tesla', 'GX');
推荐阅读
- java - 我想通过扩展字符串执行计算“添加”。怎么办?
- php - 如何知道蛋糕壳中调用了哪些控制器->动作?
- system-verilog - 状态机在 Signal Tap 上转换为不可能的状态
- highcharts - 如何在highcharts x-range中将工具提示放在点上方?
- mysql - 如果属性a为空,如何按关系属性b分组
- android - 为 react-native-video-controls 添加 TouchableOpacity
- javascript - 如何使用javascript对输入元素进行排名
- python - 如何在 scrapy 中指定 TLS 版本或禁用 TLS 验证
- angular - angular 2 bootstrap responsive 不起作用
- scala - 给定一个宽单值序列,将其分解为一系列连续子序列