{"id":3464,"date":"2017-08-15T18:42:46","date_gmt":"2017-08-15T15:42:46","guid":{"rendered":"http:\/\/kamil-abzalov.com\/tutorials\/mysql-links-between-tables-join-operator\/"},"modified":"2020-04-08T23:57:24","modified_gmt":"2020-04-08T20:57:24","slug":"mysql-links-between-tables-join-operator","status":"publish","type":"post","link":"https:\/\/kamil-abzalov.com\/en\/tutorials\/mysql\/mysql-links-between-tables-join-operator\/","title":{"rendered":"MySQL. Links between tables. JOIN operator"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; fullwidth=&#8221;on&#8221; _builder_version=&#8221;3.22&#8243;][et_pb_fullwidth_header title=&#8221;MySQL. Links between tables. JOIN operator&#8221; content_max_width=&#8221;none&#8221; _builder_version=&#8221;3.16&#8243; button_one_letter_spacing_hover=&#8221;0&#8243; button_two_letter_spacing_hover=&#8221;0&#8243; button_one_text_size__hover_enabled=&#8221;off&#8221; button_two_text_size__hover_enabled=&#8221;off&#8221; button_one_text_color__hover_enabled=&#8221;off&#8221; button_two_text_color__hover_enabled=&#8221;off&#8221; button_one_border_width__hover_enabled=&#8221;off&#8221; button_two_border_width__hover_enabled=&#8221;off&#8221; button_one_border_color__hover_enabled=&#8221;off&#8221; button_two_border_color__hover_enabled=&#8221;off&#8221; button_one_border_radius__hover_enabled=&#8221;off&#8221; button_two_border_radius__hover_enabled=&#8221;off&#8221; button_one_letter_spacing__hover_enabled=&#8221;on&#8221; button_one_letter_spacing__hover=&#8221;0&#8243; button_two_letter_spacing__hover_enabled=&#8221;on&#8221; button_two_letter_spacing__hover=&#8221;0&#8243; button_one_bg_color__hover_enabled=&#8221;off&#8221; button_two_bg_color__hover_enabled=&#8221;off&#8221;][\/et_pb_fullwidth_header][\/et_pb_section][et_pb_section fb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221; _builder_version=&#8221;3.22&#8243;][et_pb_row admin_label=&#8221;row&#8221; _builder_version=&#8221;3.25&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; custom_padding=&#8221;0px|||&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_dcsbcm_divi_breadcrumbs_module homebreadcrumbtext=&#8221;Home&#8221; hide_currentbreadcrumb=&#8221;off&#8221; _builder_version=&#8221;4.4.2&#8243; custom_padding=&#8221;0px|||&#8221; fontsbreadcrumbs_font_size_tablet=&#8221;51&#8243; fontsbreadcrumbs_line_height_tablet=&#8221;2&#8243; fontsseperator_font_size_tablet=&#8221;51&#8243; fontsseperator_line_height_tablet=&#8221;2&#8243; fontsbreadcrumblinks_font_size_tablet=&#8221;51&#8243; fontsbreadcrumblinks_line_height_tablet=&#8221;2&#8243;][\/et_pb_dcsbcm_divi_breadcrumbs_module][et_pb_text _builder_version=&#8221;3.27.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221;]In last lesson we created &#8220;sport&#8221; database and added three tables (countries, sports and teams). Furthermore we created links between tables with foreign keys. But we didn&#8217;t take into consideration one problem &#8211; how we can to delete or update data in these tables. In this lesson we&#8217;ll modify our database and make some queries simultaneously<br \/>\n[\/et_pb_text][et_pb_video src=&#8221;https:\/\/www.youtube.com\/watch?v=EOdgS9cSaZo&#8221; _builder_version=&#8221;3.0.47&#8243;][\/et_pb_video][et_pb_text _builder_version=&#8221;3.27.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221;]If you want to update or delete data in one table, and this table links with another table, you need to write <strong>on update cascade on delete restrict<\/strong> while foreign key declaration. In this situation we mean, while update data in child table data in parent table will be update. But deleting restricts. Other variants are possible, for example, <strong>set null<\/strong> &#8211; while deleting in child table null value will be set in parent table.<br \/>\nAlso we&#8217;ll consider inner join, left join and right join. Result will be the set of data from two tables.<br \/>\nAll data from first table and data which satisfy condition from the second table will be in result set while left join. Also data with null value from the second table will be in result set<br \/>\n[\/et_pb_text][et_pb_dmb_code_snippet title=&#8221;Code lesson&#8221; code=&#8221;Y3JlYXRlIHRhYmxlIGNvdW50cmllcyAoIGNvdW50cnlfaWQgaW50IHVuc2lnbmVkIG5vdCBudWxsIHByaW1hcnkga2V5IGF1dG9faW5jcmVtZW50LCBjb3VudHJ5X25hbWUgdmFyY2hhcigyNTUpIG5vdCBudWxsICk7Cmluc2VydCBpbnRvIGNvdW50cmllcyAoY291bnRyeV9pZCwgY291bnRyeV9uYW1lKSB2YWx1ZXMgKDEsICfQoNC+0YHRgdC40Y8nKSwobnVsbCwgJ9CQ0L3Qs9C70LjRjycpLChudWxsLCAn0JjRgdC\/0LDQvdC40Y8nKSwobnVsbCwgJ9CY0YLQsNC70LjRjycpLCAobnVsbCwgJ9CT0LXRgNC80LDQvdC40Y8nKSwgKG51bGwsICfQpNGA0LDQvdGG0LjRjycpOwpjcmVhdGUgdGFibGUgdGVhbXMgKCB0ZWFtX2lkIGludCB1bnNpZ25lZCBub3QgbnVsbCBwcmltYXJ5IGtleSBhdXRvX2luY3JlbWVudCwgY291bnRyeV9pZCBpbnQgdW5zaWduZWQgbm90IG51bGwsIHRlYW1fbmFtZSB2YXJjaGFyKDI1NSksIGZvcmVpZ24ga2V5KGNvdW50cnlfaWQpIHJlZmVyZW5jZXMgY291bnRyaWVzKGNvdW50cnlfaWQpIG9uIHVwZGF0ZSBjYXNjYWRlIG9uIGRlbGV0ZSByZXN0cmljdCk7Cmluc2VydCBpbnRvIHRlYW1zICh0ZWFtX2lkLCBjb3VudHJ5X2lkLCB0ZWFtX25hbWUpIHZhbHVlcyAoMSwgMSwgJ9Cm0KHQmtCQJyksIChudWxsLCAyLCAn0JzQsNC90YfQtdGB0YLQtdGAINCu0L3QsNC50YLQtdC0JyksIChudWxsLCAzLCAn0KDQtdCw0Lsg0JzQsNC00YDQuNC0JyksIChudWxsLCA0LCAn0JvQsNGG0LjQvicpLCAobnVsbCwgNSwgJ9CR0LDQstCw0YDQuNGPJyksIChudWxsLCA2LCAn0J\/QodCWJyk7CmNyZWF0ZSB0YWJsZSBwbGF5ZXJzIChwbGF5ZXJfaWQgaW50IHVuc2lnbmVkIG5vdCBudWxsIHByaW1hcnkga2V5IGF1dG9faW5jcmVtZW50LCB0ZWFtX2lkIGludCB1bnNpZ25lZCwgY291bnRyeV9pZCBpbnQgdW5zaWduZWQgbm90IG51bGwsIHBsYXllcl9uYW1lIHZhcmNoYXIoMjU1KSwgZm9yZWlnbiBrZXkodGVhbV9pZCkgcmVmZXJlbmNlcyB0ZWFtcyh0ZWFtX2lkKSBvbiB1cGRhdGUgY2FzY2FkZSBvbiBkZWxldGUgc2V0IG51bGwsIGZvcmVpZ24ga2V5KGNvdW50cnlfaWQpIHJlZmVyZW5jZXMgY291bnRyaWVzKGNvdW50cnlfaWQpIG9uIHVwZGF0ZSBjYXNjYWRlIG9uIGRlbGV0ZSByZXN0cmljdCk7&#8243; admin_label=&#8221;\u041a\u043e\u0434 \u0443\u0440\u043e\u043a\u0430&#8221; style=&#8221;docco&#8221; linenums=&#8221;on&#8221; usetabwidth=&#8221;on&#8221; tabwidth=&#8221;4&#8243; _builder_version=&#8221;4.4.2&#8243;]Y3JlYXRlIHRhYmxlIGNvdW50cmllcyAoIGNvdW50cnlfaWQgaW50IHVuc2lnbmVkIG5vdCBudWxsIHByaW1hcnkga2V5IGF1dG9faW5jcmVtZW50LCBjb3VudHJ5X25hbWUgdmFyY2hhcigyNTUpIG5vdCBudWxsICk7Cmluc2VydCBpbnRvIGNvdW50cmllcyAoY291bnRyeV9pZCwgY291bnRyeV9uYW1lKSB2YWx1ZXMgKDEsICfQoNC+0YHRgdC40Y8nKSwobnVsbCwgJ9CQ0L3Qs9C70LjRjycpLChudWxsLCAn0JjRgdC\/0LDQvdC40Y8nKSwobnVsbCwgJ9CY0YLQsNC70LjRjycpLCAobnVsbCwgJ9CT0LXRgNC80LDQvdC40Y8nKSwgKG51bGwsICfQpNGA0LDQvdGG0LjRjycpOwpjcmVhdGUgdGFibGUgdGVhbXMgKCB0ZWFtX2lkIGludCB1bnNpZ25lZCBub3QgbnVsbCBwcmltYXJ5IGtleSBhdXRvX2luY3JlbWVudCwgY291bnRyeV9pZCBpbnQgdW5zaWduZWQgbm90IG51bGwsIHRlYW1fbmFtZSB2YXJjaGFyKDI1NSksIGZvcmVpZ24ga2V5KGNvdW50cnlfaWQpIHJlZmVyZW5jZXMgY291bnRyaWVzKGNvdW50cnlfaWQpIG9uIHVwZGF0ZSBjYXNjYWRlIG9uIGRlbGV0ZSByZXN0cmljdCk7Cmluc2VydCBpbnRvIHRlYW1zICh0ZWFtX2lkLCBjb3VudHJ5X2lkLCB0ZWFtX25hbWUpIHZhbHVlcyAoMSwgMSwgJ9Cm0KHQmtCQJyksIChudWxsLCAyLCAn0JzQsNC90YfQtdGB0YLQtdGAINCu0L3QsNC50YLQtdC0JyksIChudWxsLCAzLCAn0KDQtdCw0Lsg0JzQsNC00YDQuNC0JyksIChudWxsLCA0LCAn0JvQsNGG0LjQvicpLCAobnVsbCwgNSwgJ9CR0LDQstCw0YDQuNGPJyksIChudWxsLCA2LCAn0J\/QodCWJyk7CmNyZWF0ZSB0YWJsZSBwbGF5ZXJzIChwbGF5ZXJfaWQgaW50IHVuc2lnbmVkIG5vdCBudWxsIHByaW1hcnkga2V5IGF1dG9faW5jcmVtZW50LCB0ZWFtX2lkIGludCB1bnNpZ25lZCwgY291bnRyeV9pZCBpbnQgdW5zaWduZWQgbm90IG51bGwsIHBsYXllcl9uYW1lIHZhcmNoYXIoMjU1KSwgZm9yZWlnbiBrZXkodGVhbV9pZCkgcmVmZXJlbmNlcyB0ZWFtcyh0ZWFtX2lkKSBvbiB1cGRhdGUgY2FzY2FkZSBvbiBkZWxldGUgc2V0IG51bGwsIGZvcmVpZ24ga2V5KGNvdW50cnlfaWQpIHJlZmVyZW5jZXMgY291bnRyaWVzKGNvdW50cnlfaWQpIG9uIHVwZGF0ZSBjYXNjYWRlIG9uIGRlbGV0ZSByZXN0cmljdCk7[\/et_pb_dmb_code_snippet][et_pb_comments _builder_version=&#8221;4.4.2&#8243; custom_margin=&#8221;30px||||false|false&#8221; hover_enabled=&#8221;0&#8243;][\/et_pb_comments][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In last lesson we created &#8220;sport&#8221; database and added three tables (countries, sports and teams). Furthermore we created links between tables with foreign keys. But we didn&#8217;t take into consideration one problem &#8211; how we can to delete or update data in these tables. In this lesson we&#8217;ll modify our database and make some queries [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 sport \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u043d\u0435\u0435 \u0442\u0440\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (countries, sports \u0438 teams). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u043f\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0443 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439. \u041d\u043e \u043c\u044b \u043d\u0435 \u0443\u0447\u043b\u0438 \u043e\u0434\u043d\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 - \u043a\u0430\u043a \u0431\u044b\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0443\u0434\u0430\u043b\u0438\u0442\u044c\/\u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445. \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\r\n<!--more-->\r\n\r\nhttps:\/\/www.youtube.com\/watch?v=EOdgS9cSaZo\r\n\r\n\u0427\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0435\u0439 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 - on update cascade on delete restrict. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f, \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e. \u0410 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e (restrict). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, set null - \u0442.\u0435 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u0435 \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0432 null.\r\n\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c inner join \u0438 right join (\u0442\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 left join, \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u043d\u0430 right join).\r\n\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u0440\u0438 inner join \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0442\u0430\u0431\u043b\u0438\u0446.\r\n\u041f\u0440\u0438 left join \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0435 \u043f\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u041a\u043d\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c NULL.\r\n\r\n\u041a\u043e\u0434 \u0443\u0440\u043e\u043a\u0430:\r\n\r\n<pre><code>create table countries ( country_id int unsigned not null primary key auto_increment, country_name varchar(255) not null );\r\ninsert into countries (country_id, country_name) values (1, '\u0420\u043e\u0441\u0441\u0438\u044f'),(null, '\u0410\u043d\u0433\u043b\u0438\u044f'),(null, '\u0418\u0441\u043f\u0430\u043d\u0438\u044f'),(null, '\u0418\u0442\u0430\u043b\u0438\u044f'), (null, '\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f'), (null, '\u0424\u0440\u0430\u043d\u0446\u0438\u044f');\r\ncreate table teams ( team_id int unsigned not null primary key auto_increment, country_id int unsigned not null, team_name varchar(255), foreign key(country_id) references countries(country_id) on update cascade on delete restrict);\r\ninsert into teams (team_id, country_id, team_name) values (1, 1, '\u0426\u0421\u041a\u0410'), (null, 2, '\u041c\u0430\u043d\u0447\u0435\u0441\u0442\u0435\u0440 \u042e\u043d\u0430\u0439\u0442\u0435\u0434'), (null, 3, '\u0420\u0435\u0430\u043b \u041c\u0430\u0434\u0440\u0438\u0434'), (null, 4, '\u041b\u0430\u0446\u0438\u043e'), (null, 5, '\u0411\u0430\u0432\u0430\u0440\u0438\u044f'), (null, 6, '\u041f\u0421\u0416');\r\ncreate table players (player_id int unsigned not null primary key auto_increment, team_id int unsigned, country_id int unsigned not null, player_name varchar(255), foreign key(team_id) references teams(team_id) on update cascade on delete set null, foreign key(country_id) references countries(country_id) on update cascade on delete restrict);\r\n<\/code><\/pre>","_et_gb_content_width":"","footnotes":""},"categories":[272,219],"tags":[248],"class_list":["post-3464","post","type-post","status-publish","format-standard","hentry","category-mysql","category-tutorials","tag-mysql-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL. Links between tables. JOIN operator - Kamil Abzalov&#039;s blog<\/title>\n<meta name=\"description\" content=\"We&#039;ll continue to consider links between tables and join operator.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL. Links between tables. JOIN operator - Kamil Abzalov&#039;s blog\" \/>\n<meta property=\"og:description\" content=\"We&#039;ll continue to consider links between tables and join operator.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0441\u0430\u0439\u0442 \u041a\u0430\u043c\u0438\u043b\u044f \u0410\u0431\u0437\u0430\u043b\u043e\u0432\u0430\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/kamabzalov\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-15T15:42:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-08T20:57:24+00:00\" \/>\n<meta name=\"author\" content=\"Kamil&#039; Abzalov\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"MySQL. Links between tables. JOIN operator\" \/>\n<meta name=\"twitter:description\" content=\"We&#039;ll continue to consider links between tables and join operator.\" \/>\n<meta name=\"twitter:creator\" content=\"@kamabzalov\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kamil&#039; Abzalov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/\"},\"author\":{\"name\":\"Kamil' Abzalov\",\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/#\\\/schema\\\/person\\\/9c53360f21b83306ba40c2231573c600\"},\"headline\":\"MySQL. Links between tables. JOIN operator\",\"datePublished\":\"2017-08-15T15:42:46+00:00\",\"dateModified\":\"2020-04-08T20:57:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/\"},\"wordCount\":885,\"commentCount\":0,\"keywords\":[\"mysql\"],\"articleSection\":[\"MySQL tuts\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/\",\"url\":\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/\",\"name\":\"MySQL. Links between tables. JOIN operator - Kamil Abzalov's blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/#website\"},\"datePublished\":\"2017-08-15T15:42:46+00:00\",\"dateModified\":\"2020-04-08T20:57:24+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/#\\\/schema\\\/person\\\/9c53360f21b83306ba40c2231573c600\"},\"description\":\"We'll continue to consider links between tables and join operator.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/videouroki\\\/mysql\\\/mysql-joins\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\",\"item\":\"https:\\\/\\\/kamil-abzalov.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL. Links between tables. JOIN operator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/#website\",\"url\":\"https:\\\/\\\/kamil-abzalov.com\\\/\",\"name\":\"\u0441\u0430\u0439\u0442 \u041a\u0430\u043c\u0438\u043b\u044f \u0410\u0431\u0437\u0430\u043b\u043e\u0432\u0430\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kamil-abzalov.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kamil-abzalov.com\\\/#\\\/schema\\\/person\\\/9c53360f21b83306ba40c2231573c600\",\"name\":\"Kamil' Abzalov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ad2daebcb3a4d03f8573b49054a003cd26a151ecc58ccfccc75b823131d1ead?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ad2daebcb3a4d03f8573b49054a003cd26a151ecc58ccfccc75b823131d1ead?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ad2daebcb3a4d03f8573b49054a003cd26a151ecc58ccfccc75b823131d1ead?s=96&d=mm&r=g\",\"caption\":\"Kamil' Abzalov\"},\"sameAs\":[\"https:\\\/\\\/kamil-abzalov.com\\\/\",\"https:\\\/\\\/www.facebook.com\\\/kamabzalov\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/kamabzalov\",\"https:\\\/\\\/x.com\\\/kamabzalov\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/kamabzalov\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL. Links between tables. JOIN operator - Kamil Abzalov's blog","description":"We'll continue to consider links between tables and join operator.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/","og_locale":"en_US","og_type":"article","og_title":"MySQL. Links between tables. JOIN operator - Kamil Abzalov's blog","og_description":"We'll continue to consider links between tables and join operator.","og_url":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/","og_site_name":"\u0441\u0430\u0439\u0442 \u041a\u0430\u043c\u0438\u043b\u044f \u0410\u0431\u0437\u0430\u043b\u043e\u0432\u0430","article_author":"https:\/\/www.facebook.com\/kamabzalov","article_published_time":"2017-08-15T15:42:46+00:00","article_modified_time":"2020-04-08T20:57:24+00:00","author":"Kamil' Abzalov","twitter_card":"summary_large_image","twitter_title":"MySQL. Links between tables. JOIN operator","twitter_description":"We'll continue to consider links between tables and join operator.","twitter_creator":"@kamabzalov","twitter_misc":{"Written by":"Kamil' Abzalov","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/#article","isPartOf":{"@id":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/"},"author":{"name":"Kamil' Abzalov","@id":"https:\/\/kamil-abzalov.com\/#\/schema\/person\/9c53360f21b83306ba40c2231573c600"},"headline":"MySQL. Links between tables. JOIN operator","datePublished":"2017-08-15T15:42:46+00:00","dateModified":"2020-04-08T20:57:24+00:00","mainEntityOfPage":{"@id":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/"},"wordCount":885,"commentCount":0,"keywords":["mysql"],"articleSection":["MySQL tuts","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/","url":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/","name":"MySQL. Links between tables. JOIN operator - Kamil Abzalov's blog","isPartOf":{"@id":"https:\/\/kamil-abzalov.com\/#website"},"datePublished":"2017-08-15T15:42:46+00:00","dateModified":"2020-04-08T20:57:24+00:00","author":{"@id":"https:\/\/kamil-abzalov.com\/#\/schema\/person\/9c53360f21b83306ba40c2231573c600"},"description":"We'll continue to consider links between tables and join operator.","breadcrumb":{"@id":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kamil-abzalov.com\/videouroki\/mysql\/mysql-joins\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430","item":"https:\/\/kamil-abzalov.com\/en\/"},{"@type":"ListItem","position":2,"name":"MySQL. Links between tables. JOIN operator"}]},{"@type":"WebSite","@id":"https:\/\/kamil-abzalov.com\/#website","url":"https:\/\/kamil-abzalov.com\/","name":"\u0441\u0430\u0439\u0442 \u041a\u0430\u043c\u0438\u043b\u044f \u0410\u0431\u0437\u0430\u043b\u043e\u0432\u0430","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kamil-abzalov.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kamil-abzalov.com\/#\/schema\/person\/9c53360f21b83306ba40c2231573c600","name":"Kamil' Abzalov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3ad2daebcb3a4d03f8573b49054a003cd26a151ecc58ccfccc75b823131d1ead?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3ad2daebcb3a4d03f8573b49054a003cd26a151ecc58ccfccc75b823131d1ead?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ad2daebcb3a4d03f8573b49054a003cd26a151ecc58ccfccc75b823131d1ead?s=96&d=mm&r=g","caption":"Kamil' Abzalov"},"sameAs":["https:\/\/kamil-abzalov.com\/","https:\/\/www.facebook.com\/kamabzalov","https:\/\/www.linkedin.com\/in\/kamabzalov","https:\/\/x.com\/kamabzalov","https:\/\/www.youtube.com\/user\/kamabzalov"]}]}},"_links":{"self":[{"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/posts\/3464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/comments?post=3464"}],"version-history":[{"count":8,"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/posts\/3464\/revisions"}],"predecessor-version":[{"id":31868,"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/posts\/3464\/revisions\/31868"}],"wp:attachment":[{"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/media?parent=3464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/categories?post=3464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kamil-abzalov.com\/en\/wp-json\/wp\/v2\/tags?post=3464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}