I am new to mysql views,just came along this problem
I have 3 tables
personal(name,age,village)
office(id,company,location)
entertainment(sport,team,music)
Now I create a view using the following syntax
mysql> CREATE VIEW person AS
-> SELECT personal.name,personal.age,personal.village,office.id,office.comp
any,office.location,entertainment.sport,entertainment.team,entertainment.music
-> FROM personal,office,entertainment;
Next I insert into person view
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');
I get the output with this properly.(I had to insert sepeartely or else it gives me an error)
+------+------+---------+-------+---------+----------+----------+------+-------+
| name | age | village | id | company | location | sport | team | music |
+------+------+---------+-------+---------+----------+----------+------+-------+
| jay | 40 | Pune | 36234 | AZcD | Mumbai | football | KKR | POP |
+------+------+---------+-------+---------+----------+----------+------+-------+
The problem arises now,when I try to insert the same insert queries again with different values ,I get the following output
+-------+------+---------+-------+---------+----------+------------+------+-----
------+
| 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 |
+-------+------+---------+-------+---------+----------+------------+------+-----
------+
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:
mysql> select * from personal;
+-------+------+---------+
| name | age | village |
+-------+------+---------+
| jay | 40 | Pune |
| Rohit | 42 | Goa |
+-------+------+---------+
2 rows in set (0.00 sec)
mysql> select * from office;
+-------+---------+----------+
| id | company | location |
+-------+---------+----------+
| 36234 | AZcD | Mumbai |
| 86234 | YZcD | Kolkata |
+-------+---------+----------+
2 rows in set (0.00 sec)
mysql> select * from entertainment;
+------------+------+-----------+
| sport | team | music |
+------------+------+-----------+
| football | KKR | POP |
| basketball | CSK | Bollywood |
+------------+------+-----------+
2 rows in set (0.00 sec)
Please help.