Cause lot of task in the office lately so I haven't had as much time to post any note, so here I would like to make a note about Join Query in MySQL.
The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. Tables in a database are often related to each other with keys. So we can get data easier to read as what we want.
Assume that we have table and we'll try to make a relation, we make a simple table which have structure as below :
Table user:
The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. Tables in a database are often related to each other with keys. So we can get data easier to read as what we want.
Assume that we have table and we'll try to make a relation, we make a simple table which have structure as below :
Table user:
CREATE TABLE `user` ( `id_user` int(11) NOT NULL auto_increment, `name` varchar(20) NOT NULL, PRIMARY KEY (`id_user`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;Table user_description :
CREATE TABLE `user_description` ( `id_user` int(11) NOT NULL, `address` varchar(50) NOT NULL, `telephone` varchar(15) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;Data :
INSERT INTO `user` (`id_user`, `name`) VALUES (1, 'anto purwanto'), (2, 'johnny'), (3, 'kartikarina'); INSERT INTO `user_description` (`id_user`, `address`, `telephone`) VALUES (1, 'cimahi', '082550435544'), (2, 'cibiru', '022 7823413'), (4, 'tubagus ismail', '022 66224325');
