SQL result changes when select statement changes

So, currently we are doing SQL @ our school and I was interested to know about a suspicious result set when changing the selection parameters.

So when I try this:

select p1.vorname, p1.Geburtstag, p2.vorname, p2.Geburtstag
from patienten as p1
inner join patienten as p2 
    on p1.Geburtstag = p2.Geburtstag AND p1.Nr != p2.Nr
order by p1.Geburtstag asc

Then I get 44 results. But when I try this:

select p1.vorname, p1.Geburtstag
    from patienten as p1
    inner join patienten as p2 
        on p1.Geburtstag = p2.Geburtstag AND p1.Nr != p2.Nr
    order by p1.Geburtstag asc

I get 1084 results that represent all patients ...

I wonder why, because all I did was change the select statement ...

I am using XAMPP:

Server: 127.0.0.1 via TCP/IP
Server-Typ: MariaDB
Server-Version: 10.1.8-MariaDB-log - mariadb.org binary distribution
Protokoll-Version: 10
Benutzer: root@localhost
Server-Zeichensatz: UTF-8 Unicode (utf8)
+4
source share
1 answer

, MySQL, , , . , != MySQL. , ( ) ! =:

select p1.vorname, p1.Geburtstag
    from patienten as p1
    inner join patienten as p2 
        on p1.Geburtstag = p2.Geburtstag 
    where p1.Nr != p2.Nr
    order by p1.Geburtstag asc

,

0

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


All Articles