1
Good afternoon, I’m having trouble with this Mysql question:
Show the name of the animals and the breed code. Just show the animals that contain in their respective code a prime number from 0 to 10.
I tried with the following code:
SELECT nome, raca from animais where
(codigo > 0 and codigo < 10)
and (codigo % 1 = 0 and codigo % 2 = 0) or (codigo % 1 = 0 and codigo % 3 = 0) or
(codigo % 1 = 0 and codigo % 5 = 0) or (codigo % 1 = 0 and codigo % 7 = 0)
Makes the following mistake, only:
Error = { Answer with Error }
Because I am solving questions of sqlweb.com.br. Following the image of the site with the question, the answer and the error:
Edit the question with the error generated.
– Mauro Alexandre
Tip: your verification can be simplified to
codigo in (2, 3, 5, 7)
, because you know that those are the prime numbers between 0 and 10 - and that won’t change anytime soon.– Woss
The "contain" of the statement is ambiguous. Worth codes that have a digit cousin?
– bfavaretto
@bfavaretto I understood that it is worth any code that has a prime digit, such as 34 enter, since 3 is prime. But it is very confusing.
– Woss
in (2, 3, 5, 7) code gives error
– João Ricardo
Any number is divisible by 1 and therefore the rest of the division of any integer by 1 will always be zero.
– anonimo