0

I'm trying to insert some dates into a table. I know how to insert values if the dates are statics, I mean "4", "car", "1456", etc, and I also know how to insert one query answer into a table, but I don't know how to do it when I want to insert the answers of more than one query.

I want to insert into the restaurant table two values:

insert into restaurant (id_restaurant, id_category)

These values are the answer of two querys.

select id_rest from restaurant_menu where name = "discount" 
select id_cat from category_menu where name = "beach";

How I can insert into id_restaurant and id_category, id_cat and id_cat respectively?

Please, could you help me? I have searched for this many times but I haven't find it.

HQCasanova
  • 1,158
  • 1
  • 10
  • 15

1 Answers1

1

Do you want the Cartesian product inserted?

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";
Michael Mairegger
  • 6,833
  • 28
  • 41
AgRizzo
  • 5,261
  • 1
  • 13
  • 28