Reputation: 23141
I have three tables
+--id---ident---+
|--1----menu_1--|
+--id---id_parent---name---------id_lang--+
|--1----1-----------menu_eng------1-------|
|--2----1-----------menu_rus------2-------|
+--3----1-----------menu_arm------3-------+
+--id---name--------+
|--1----english-----|
|--2----russian-----|
|--3----armenian----|
second table store the data about menus (names in all languages), ie. id_parent of second table is id of first.
let's asume i add a new language, with id=4. now i need to give the default values( which must br equal to id_lang
= 1 value) to all menus, so i need to add row in menus_data
table
|--4----1-----------menu_eng------4-------|
and i must do it with all menus from menus
table.
I can do it with tree queries -
menus
tablemenus_content
table with that valuesbut maybe it is possible to do in one query?
Thanks
Upvotes: 1
Views: 92
Reputation: 30394
I think it's possible. It would be something like this:
insert into `menus_data` select null, `id_parent`, `name`, 4 from `menus_data` where `id_lang` = 1;
I haven't checked that, so the syntax may be a little off. The query also assumes that there is a record for id_lang=1 in menus_data for every menu.
More info on this type of query here: http://dev.mysql.com/doc/refman/5.1/en/insert-select.html
Upvotes: 1