MYSQL - Where with relationship does not resume result

Asked

Viewed 33 times

0

I need to use this Where in a query, but without success

With 'AND' does not work.

    where ((`atributos_detalhes`.`keyValue` = 'dormitorios' and `relation_imovel_detalhes`.`value` in (2)) **AND**
(`atributos_detalhes`.`keyValue` = 'areaTerreno' and `relation_imovel_detalhes`.`value` > 0))

So it works with "or" between them, but not as you would like

where ((`atributos_detalhes`.`keyValue` = 'dormitorios' and `relation_imovel_detalhes`.`value` in (2)) **OR**
    (`atributos_detalhes`.`keyValue` = 'areaTerreno' and `relation_imovel_detalhes`.`value` > 0))
  • 1

    My friend: you have to know a minimum of logic to know if you want to build your expression using the logical connectors AND or OR. There’s no sense in you replacing each other without knowing why.

  • 1

    I understand the logical operators, the point is that I need to use the AND, but the end doesn’t work, I can use the OR, but not as the AND would be. So I would like a way to make this possible. As described in the codes. Thank you for the answer.

  • probably not that it doesn’t work, but all conditions together should not occur

  • You start your comment with "I understand the logical operators" but what you put below gives the opposite impression. Without you describing what you want to get no one can opine on which of the two expressions you posted is correct or whether they are both wrong.

  • 1

    It makes no sense, in the first parentheses you have keyValue = 'dormitorios', and in the second keyValue = 'areaTerreno', never both checks will return true, either is one or is another. If you want help, explain what each field is, show the table structure and exemplify the output you want

1 answer

0

You built an expression that wishes an attribute (keyValue) has two values, which will not be possible.

keyValue = 'dormitorios' AND keyValue = 'areaTerrene'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.