Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8007317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:47:05+00:00 2026-06-04T17:47:05+00:00

I have two tables: CREATE TABLE IF NOT EXISTS treaties( id INT NOT NULL

  • 0

I have two tables:

CREATE TABLE IF NOT EXISTS treaties(
id INT NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
PRIMARY KEY(id)
)ENGINE=InnoDB;

and

CREATE TABLE IF NOT EXISTS items(
id INT NOT NULL AUTO_INCREMENT,
treaty INT NOT NULL,
item varchar(20),
PRIMARY KEY(id),
FOREIGN KEY (treaty) REFERENCES treaties(id)
      ON UPDATE RESTRICT
      ON DELETE RESTRICT
)ENGINE=InnoDB;

After that I inserted few lines in each of tables but values treaties.id and items.treaty were the same.
When I run

EXPLAIN SELECT * 
FROM `items` 
JOIN `treaties` ON `items`.`treaty` = `treaties`.`id` 
WHERE 1

I obtained:

id | select_type | table   | type | possible_keys | key | key_len | ref | rows | Extra
1  | SIMPLE      | treaties| ALL  | PRIMARY       | NULL|   NULL  | NULL|   3  |
1  | SIMPLE      | items   | ALL  | treaty        | NULL|   NULL  | NULL|   4  | Using where; Using join buffer

I thought if I have foreign key between items.treaty and treaties.id this key must used and type must not be ALL.
What is wrong?

Please, help me!

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:47:07+00:00Added an answer on June 4, 2026 at 5:47 pm

    As explained in the manual:

    The output from EXPLAIN shows ALL in the type column when MySQL uses a table scan to resolve a query. This usually happens under the following conditions:

    […]

    • The table is so small that it is faster to perform a table scan than to bother with a key lookup. This is common for tables with fewer than 10 rows and a short row length. Don’t worry in this case.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two SQL statements: CREATE TABLE legs(legid INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
I have two tables: CREATE TABLE dbo.country ( cntry_id VARCHAR(2) NOT NULL, name VARCHAR(50)
So I have two tables structured like so: CREATE TABLE #nodes(node int NOT NULL);
I have two tables : create table CurrentDay ( ID int identity primary key,
i have two tables CREATE TABLE IF NOT EXISTS `user` ( `user_id` int(20) NOT
I have two tables: CREATE TABLE IF NOT EXISTS `comments` ( `id` int(11) NOT
I have two tables: CREATE TABLE [dbo].[Task]( [SysTask] [int] IDENTITY(1,1) NOT NULL, [TaskStatus] [int]
I have two tables. Table user : CREATE TABLE IF NOT EXISTS `user` (
I have got a problem with two tables: CREATE TABLE IF NOT EXISTS `addresses`
I have two mysql tables: /* Table users */ CREATE TABLE IF NOT EXISTS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.