Questions about mysql foreign key queries, such as the following figure and code

< H2 > set up two tables as follows. How can curd change the two tables at the same time, that is, query the data of the two tables? in addition, do you use this method much in the actual project < / H2 >? < H2 > my_class < / H2 >
CREATE TABLE `my_class` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `c_name` varchar(20) NOT NULL,
  `room` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
< H2 > my_foreign1 < / H2 >
CREATE TABLE `my_foreign1` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL COMMENT "",
  `c_id` int(11) DEFAULT NULL COMMENT "id",
  PRIMARY KEY (`id`),
  KEY `c_id` (`c_id`),
  CONSTRAINT `my_foreign1_ibfk_1` FOREIGN KEY (`c_id`) REFERENCES `my_class` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
< H2 > only single table queries < / H2 >

my_foreign1

use test521;
insert into my_foreign1 (name,c_id) VALUES ("cccc",1);
update my_foreign1 set name = "ccccccc" where id = 1;
select * from my_foreign1;
delete from my_foreign1 where id =1;

my_class

insert into my_class (name,room) VALUES ("aaa",1);
insert into my_class (name,room) VALUES ("bbb",2);

an insert statement can insert only one table.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2bbeb-2baa2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2bbeb-2baa2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?