Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert in mysql view gives wrong output
    primarykey
    data
    text
    <p>I am new to mysql views,just came along this problem I have 3 tables</p> <pre><code>personal(name,age,village) office(id,company,location) entertainment(sport,team,music) </code></pre> <p>Now I create a view using the following syntax</p> <pre><code>mysql&gt; CREATE VIEW person AS -&gt; SELECT personal.name,personal.age,personal.village,office.id,office.comp any,office.location,entertainment.sport,entertainment.team,entertainment.music -&gt; FROM personal,office,entertainment; </code></pre> <p>Next I insert into person view </p> <pre><code> INSERT INTO person(name,age,village) VALUES ('jay','40','Pune'); INSERT INTO person(id,company,location) VALUES ('36234','AZcD','Mumbai'); INSERT INTO person(sport,team,music) VALUES ('football','KKR','POP'); </code></pre> <p>I get the output with this properly.(I had to insert sepeartely or else it gives me an error)</p> <pre><code> +------+------+---------+-------+---------+----------+----------+------+-------+ | name | age | village | id | company | location | sport | team | music | +------+------+---------+-------+---------+----------+----------+------+-------+ | jay | 40 | Pune | 36234 | AZcD | Mumbai | football | KKR | POP | +------+------+---------+-------+---------+----------+----------+------+-------+ </code></pre> <p>The problem arises now,when I try to insert the same insert queries again with different values ,I get the following output</p> <pre><code>+-------+------+---------+-------+---------+----------+------------+------+----- ------+ | name | age | village | id | company | location | sport | team | musi c | +-------+------+---------+-------+---------+----------+------------+------+----- ------+ | jay | 40 | Pune | 36234 | AZcD | Mumbai | football | KKR | POP | | Rohit | 42 | Goa | 36234 | AZcD | Mumbai | football | KKR | POP | | jay | 40 | Pune | 86234 | YZcD | Kolkata | football | KKR | POP | | Rohit | 42 | Goa | 86234 | YZcD | Kolkata | football | KKR | POP | | jay | 40 | Pune | 36234 | AZcD | Mumbai | basketball | CSK | Boll ywood | | Rohit | 42 | Goa | 36234 | AZcD | Mumbai | basketball | CSK | Boll ywood | | jay | 40 | Pune | 86234 | YZcD | Kolkata | basketball | CSK | Boll ywood | | Rohit | 42 | Goa | 86234 | YZcD | Kolkata | basketball | CSK | Boll ywood | +-------+------+---------+-------+---------+----------+------------+------+----- ------+ </code></pre> <p>I get 7 new records instead of just 1.And if you see closely the last record is the right record,I mean the record i inserted. What am I doin wrong? The tables are proper after the above queries:</p> <pre><code>mysql&gt; select * from personal; +-------+------+---------+ | name | age | village | +-------+------+---------+ | jay | 40 | Pune | | Rohit | 42 | Goa | +-------+------+---------+ 2 rows in set (0.00 sec) mysql&gt; select * from office; +-------+---------+----------+ | id | company | location | +-------+---------+----------+ | 36234 | AZcD | Mumbai | | 86234 | YZcD | Kolkata | +-------+---------+----------+ 2 rows in set (0.00 sec) mysql&gt; select * from entertainment; +------------+------+-----------+ | sport | team | music | +------------+------+-----------+ | football | KKR | POP | | basketball | CSK | Bollywood | +------------+------+-----------+ 2 rows in set (0.00 sec) </code></pre> <p>Please help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload