作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将一些日期插入表中。我知道如何在日期是静态的情况下插入值,我的意思是“4”、“汽车”、“1456”等,而且我也知道如何将一个查询答案插入表中,但我不知道如何当我想插入多个查询的答案时,请执行此操作。
我想在餐厅表中插入两个值:
insert into restaurant (id_restaurant, id_category)
这些值是两个查询的答案。
select id_rest from restaurant_menu where name = "discount"
select id_cat from category_menu where name = "beach";
如何分别插入 id_restaurant 和 id_category、id_cat 和 id_cat?
请问你能帮我吗?我已经搜索了很多次但没有找到它。
最佳答案
您想要插入笛卡尔积吗?
INSERT INTO restaurant (id_restaurant, id_category)
SELECT id_rest, id_cat
FROM restaurant_menu rm, category_menu cm
WHERE rm.name = "discount" AND cm.name = "beach";
关于mysql - 如何将不同的查询答案插入到表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19964644/
我是一名优秀的程序员,十分优秀!