1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] "Limit 1" SQL Query giving more than 1 result [closed]

Discussão em 'Outras Linguagens' iniciado por Stack, Novembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    What I'm trying to do is: for a given English ID, select all Spanish sentences that share that ID. But some of the results are returning multiple sentences with different ids, despite setting the English limit to 1. The English table doesn't repeat the ID, but the Spanish table does. Am I missing something super obvious here? Using MySQL/PopSQL.

    SELECT spanish.sentence
    FROM spanish
    WHERE spanish.id = (
    SELECT english.id
    FROM english
    ORDER BY RAND()
    LIMIT 1
    );


    Example data:

    Spanish

    ID sentence
    1 un chico
    2 un jugador
    2 una jugadora
    3 una mujer

    English

    ID sentence
    1 a boy
    2 a player
    3 a woman

    So the expected result from randomly choosing English "2" would be both "un jugador" and "una jugadora". But what I'm getting sometimes is "un chico" and "una jugadora" (2 different IDs) having set the ID limit to 1.

    Continue reading...

Compartilhe esta Página