Search code examples
mysqldatagrip

getting different values, by condition becoming more specific


I have two pieces of code

SELECT * FROM etel.ti18n_country
                  inner join etel.ti18n
                  ON id_i18nid = i18nid WHERE id_countryid = 1

and

SELECT * FROM etel.ti18n_country
                  inner join etel.ti18n
                  ON id_i18nid = i18nid WHERE id_countryid = 1 and id_i18nid = 4460;

the first results in a bunch of results, but noticably none with id_i18nid = 4460

the second, however gets the result with id_i18nid = 4460.

how can that be? As I understand mysql the first piece of code should've had a result id_i18nid = 4460 for it to be possible for the second piece to have it aswell. Since I made the where clause more specific


Solution

  • Turns out the problem was that I was using Datagrips' ordering to find my id. since I had more than 500 results, datagrip takes random results and orders those. by ending the statement with ORDER BY id_i18nid DESC I found the result.