Skip to content

Query results are not as expected #7177

@zengnm

Description

@zengnm

environment:

CREATE TABLE `tablea` (
  `id` int NOT NULL AUTO_INCREMENT,
  `start` int NOT NULL,
  `end` int NOT NULL,
  `name` varchar(32),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;
INSERT INTO tablea (id, start, end, name) VALUES (1, 603000, 605001, 'test');

CREATE TABLE `tableb` (
  `id` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;
INSERT INTO tableb (id) VALUES (600000);
INSERT INTO tableb (id) VALUES (605000);
INSERT INTO tableb (id) VALUES (608000);

query sql:

SELECT a.id
FROM (select 'test' as name) h
     JOIN tablea a ON h.name = a.name
     JOIN tableb b ON b.id between a.start AND a.end;

Result set is empty. But there should be a record that can be found

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions