Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
Jony Walker

Erro De Consulta

Question

Tenho a seguinte consulta:

SELECT * FROM doutores WHERE espec = 'cardiologia' OR espec2 = 'cardiologia' OR espec3 = 'cardiologia' AND regiao = 'norte' ORDER BY id

Clique na lupa para obter mais informações:

O AND está sendo ignorado, porque ele traz todos os cardiologistas, independente da região... como posso arrumar isso ??

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Troque por isso:

SELECT * FROM doutores WHERE (espec = 'cardiologia' OR espec2 = 'cardiologia' OR espec3 = 'cardiologia') AND regiao = 'norte' ORDER BY id

[]s!

Share this post


Link to post
Share on other sites
  • 0

Obrigado, funcionou !! Acho q ele estava considerando o AND como parte complementar somente da espec3 = 'cardiologia' e não como parte do todo da query...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  



  • Forum Statistics

    • Total Topics
      148092
    • Total Posts
      643316
×
×
  • Create New...