Insert records in chunk to mysql view

379 views Asked by At

I have created empty view with following query:

CREATE VIEW `test` AS select * from `configurations` where 0;

Consider configurations table have 100 records with primary key id starting from 0 to 100.

I would like to insert data in view with chunk of 10 within loop.

I could not get any solution for the same. Can anyone give a bit of hint.


Update: Following steps I want to perform.

  1. Create empty view (I achieved this)
  2. I have base table with 100 records in it.
  3. Now, I want my view to represent any 10 records based on id like [where id IN (1,5,8,3,6,67,34,23,45,99)]
  4. Again after some operations I would like more 10 records to be selected from base table. like [where id IN (11,55,88,33,66,27,43,23,15,19)]

Hope I am clear enough.

1

There are 1 answers

2
puppyFlo On

OK, I'll try again.

This is a misinterpreation of what a view does - a view should be used to inspect existing data from actual table(s) in a fixed manner such that a view could be used to show all configurations with ID value less than 25 etc.

What you have described sounds like all you need to do is issue selects to your main table with a different list of ID's to retrieve.

Is there any reason you aren't doing this:

SELECT * FROM configurations WHERE id in (1,4,6,7,8,9);
SELECT * FROM configurations WHERE id in (5,51,2,45,6);

?

EDIT:

Add a column to your configuration table as an "in view" indicator. Update your view to only display records where in_view = 1. Then simply update the configurations table and set those interesting records to in_view=1

Hope that helps?