What does phpMyAdmin do for my UNION ALL request?

The following query returns 1 row:

SELECT `coach_id` FROM `table_a` WHERE `coach_id` = 8
UNION ALL
SELECT `coach_id` FROM `table_b` WHERE `coach_id` = 8

But it SELECT coach_id FROM table_b WHERE coach_id = 8returns 2 rows.

And it SELECT coach_id FROM table_a WHERE coach_id = 8returns 1 row.

I use UNION ALLto avoid filtering DISTINCTbecause I'm just interested in the total number of rows. However, it seems to behave like an ordinary UNIONaka UNION DISTINCT.

What's going on here? The request is executed in the phpMyAdmin interface 4.5.2on the MariaDB server 10.1.9.

Update

I just found that the mysql command line client behaves as expected. So the crash should be somewhere inside my package nginx 1.8.0, PHP 5.6.16 mysqliand phpmyadmin.

Update 2

php script ( mysqli), 3 . , , phpMyAdmin, . , . ...

+4
3

phpMyAdmin, ​​ v4.5.3.0 (2015-12-23). ​​

+1

create schema testThenDrop123;
use testThenDrop123; -- use that database

create table table_a
(   id int auto_increment primary key,
    coach_id int not null
);

create table table_b
(   id int auto_increment primary key,
    coach_id int not null
);

insert table_a (coach_id) values (8);
insert table_b (coach_id) values (8),(8);

SELECT `coach_id` FROM `table_a` WHERE `coach_id` = 8 
UNION ALL 
SELECT `coach_id` FROM `table_b` WHERE `coach_id` = 8;
+----------+
| coach_id |
+----------+
|        8 |
|        8 |
|        8 |
+----------+

.

drop schema testThenDrop123; -- cleanup by dropping db

, , .

0

, ? - ? LENGTH (coach_id), coach_id . , , , , .

0

Source: https://habr.com/ru/post/1619674/


All Articles