0

I have a table MG_DEVICE_GROUP_IN_GEOZONE that has two columns

| deviceGroup_id| geozone_id|
| ------------- | --------- |

I want to insert multiple values to both columns:

  • in geozone_id should be all ids from nested query
  • in deviceGroup_id should be one value for all - 4525

I'm tried to use this query:

insert into MG_DEVICE_GROUP_IN_GEOZONE (deviceGroup_id, geozone_id)
values (4525, (select id from MG_GEOZONE where account_id = 114 and zoneType in (0, 1 , 3)));

But I receiving error - "[21000][1242] Subquery returns more than 1 row"

I understand why this error appeared but I can't find the right query to do this. Please help me. Thanks

1 Answer 1

1
insert into MG_DEVICE_GROUP_IN_GEOZONE (deviceGroup_id, geozone_id)
select 4525,id from MG_GEOZONE where account_id = 114 and zoneType in (0, 1 , 3);

The INSERT statement can be followed by a SELECT statement, which produces the values to be inserted.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.