Where clause with like and not like operators not working
I have this query:
SELECT
DISTINCT
REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM [TABELA DE PRECOS] AS A
LEFT JOIN DE_PARA_SAP_APARELHOS AS B
ON (A.[NOME DPGC] = B.APARELHODPAV)
WHERE PLANO LIKE '%CONTROLE%'
AND PLANO NOT LIKE '%Renova%'
AND A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet')
AND REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
AND A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
I've searched a bit and found that if you have null values, LIKE and NOT LIKE could not work properly, so i'm using ISNULL. But i'm still getting values that contains 'Renova':
Novo Vivo V (Renova)
Novo Vivo V
Vivo Família 70GB (Renova)
Vivo Família 50GB (Renova)
Vivo Família 70GB
Vivo Controle....
I don't get any error messages. The query runs fine, but it's like my like and not like operators are being ignored or something like that. What am i missing here?
sql sql-server-2012
add a comment |
I have this query:
SELECT
DISTINCT
REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM [TABELA DE PRECOS] AS A
LEFT JOIN DE_PARA_SAP_APARELHOS AS B
ON (A.[NOME DPGC] = B.APARELHODPAV)
WHERE PLANO LIKE '%CONTROLE%'
AND PLANO NOT LIKE '%Renova%'
AND A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet')
AND REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
AND A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
I've searched a bit and found that if you have null values, LIKE and NOT LIKE could not work properly, so i'm using ISNULL. But i'm still getting values that contains 'Renova':
Novo Vivo V (Renova)
Novo Vivo V
Vivo Família 70GB (Renova)
Vivo Família 50GB (Renova)
Vivo Família 70GB
Vivo Controle....
I don't get any error messages. The query runs fine, but it's like my like and not like operators are being ignored or something like that. What am i missing here?
sql sql-server-2012
2
It's not the(NOT) LIKE
. When you format your query (I did it for you) it's easier to spot that there's anOR
ed condition.AND
has a higher precedence thanOR
, you probably don't want that --> add parens around theOR
ed condition.AND (REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND A.[REGIAO] = '7x'
. Btw, you should always use parens when you mixAND
andOR
– dnoeth
Nov 12 at 15:19
@dnoeth dont know why you didnt make it an answer
– Juan Carlos Oropeza
Nov 12 at 15:24
LIKE and NOT LIKE could not work properly, so i'm using ISNULL
..... I dont see ISNULL anywhere
– Juan Carlos Oropeza
Nov 12 at 15:25
add a comment |
I have this query:
SELECT
DISTINCT
REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM [TABELA DE PRECOS] AS A
LEFT JOIN DE_PARA_SAP_APARELHOS AS B
ON (A.[NOME DPGC] = B.APARELHODPAV)
WHERE PLANO LIKE '%CONTROLE%'
AND PLANO NOT LIKE '%Renova%'
AND A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet')
AND REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
AND A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
I've searched a bit and found that if you have null values, LIKE and NOT LIKE could not work properly, so i'm using ISNULL. But i'm still getting values that contains 'Renova':
Novo Vivo V (Renova)
Novo Vivo V
Vivo Família 70GB (Renova)
Vivo Família 50GB (Renova)
Vivo Família 70GB
Vivo Controle....
I don't get any error messages. The query runs fine, but it's like my like and not like operators are being ignored or something like that. What am i missing here?
sql sql-server-2012
I have this query:
SELECT
DISTINCT
REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM [TABELA DE PRECOS] AS A
LEFT JOIN DE_PARA_SAP_APARELHOS AS B
ON (A.[NOME DPGC] = B.APARELHODPAV)
WHERE PLANO LIKE '%CONTROLE%'
AND PLANO NOT LIKE '%Renova%'
AND A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet')
AND REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB'
AND A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
I've searched a bit and found that if you have null values, LIKE and NOT LIKE could not work properly, so i'm using ISNULL. But i'm still getting values that contains 'Renova':
Novo Vivo V (Renova)
Novo Vivo V
Vivo Família 70GB (Renova)
Vivo Família 50GB (Renova)
Vivo Família 70GB
Vivo Controle....
I don't get any error messages. The query runs fine, but it's like my like and not like operators are being ignored or something like that. What am i missing here?
sql sql-server-2012
sql sql-server-2012
edited Nov 12 at 15:22
dnoeth
44.6k31838
44.6k31838
asked Nov 12 at 15:12
Joao Victor
47431127
47431127
2
It's not the(NOT) LIKE
. When you format your query (I did it for you) it's easier to spot that there's anOR
ed condition.AND
has a higher precedence thanOR
, you probably don't want that --> add parens around theOR
ed condition.AND (REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND A.[REGIAO] = '7x'
. Btw, you should always use parens when you mixAND
andOR
– dnoeth
Nov 12 at 15:19
@dnoeth dont know why you didnt make it an answer
– Juan Carlos Oropeza
Nov 12 at 15:24
LIKE and NOT LIKE could not work properly, so i'm using ISNULL
..... I dont see ISNULL anywhere
– Juan Carlos Oropeza
Nov 12 at 15:25
add a comment |
2
It's not the(NOT) LIKE
. When you format your query (I did it for you) it's easier to spot that there's anOR
ed condition.AND
has a higher precedence thanOR
, you probably don't want that --> add parens around theOR
ed condition.AND (REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND A.[REGIAO] = '7x'
. Btw, you should always use parens when you mixAND
andOR
– dnoeth
Nov 12 at 15:19
@dnoeth dont know why you didnt make it an answer
– Juan Carlos Oropeza
Nov 12 at 15:24
LIKE and NOT LIKE could not work properly, so i'm using ISNULL
..... I dont see ISNULL anywhere
– Juan Carlos Oropeza
Nov 12 at 15:25
2
2
It's not the
(NOT) LIKE
. When you format your query (I did it for you) it's easier to spot that there's an OR
ed condition. AND
has a higher precedence than OR
, you probably don't want that --> add parens around the OR
ed condition. AND (REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND A.[REGIAO] = '7x'
. Btw, you should always use parens when you mix AND
and OR
– dnoeth
Nov 12 at 15:19
It's not the
(NOT) LIKE
. When you format your query (I did it for you) it's easier to spot that there's an OR
ed condition. AND
has a higher precedence than OR
, you probably don't want that --> add parens around the OR
ed condition. AND (REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND A.[REGIAO] = '7x'
. Btw, you should always use parens when you mix AND
and OR
– dnoeth
Nov 12 at 15:19
@dnoeth dont know why you didnt make it an answer
– Juan Carlos Oropeza
Nov 12 at 15:24
@dnoeth dont know why you didnt make it an answer
– Juan Carlos Oropeza
Nov 12 at 15:24
LIKE and NOT LIKE could not work properly, so i'm using ISNULL
..... I dont see ISNULL anywhere– Juan Carlos Oropeza
Nov 12 at 15:25
LIKE and NOT LIKE could not work properly, so i'm using ISNULL
..... I dont see ISNULL anywhere– Juan Carlos Oropeza
Nov 12 at 15:25
add a comment |
2 Answers
2
active
oldest
votes
brackets missing on OR clause:
SELECT DISTINCT REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM @A AS A
LEFT JOIN @B AS B ON
A.[NOME DPGC] = B.APARELHODPAV
WHERE PLANO LIKE '%CONTROLE%' AND
PLANO NOT LIKE '%Renova%' AND
A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet') AND
(REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND
A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
add a comment |
If you do not want to include Renova, do not include it in your where clause and it will be exempted from the selection. That will solve your problem.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265026%2fwhere-clause-with-like-and-not-like-operators-not-working%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
brackets missing on OR clause:
SELECT DISTINCT REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM @A AS A
LEFT JOIN @B AS B ON
A.[NOME DPGC] = B.APARELHODPAV
WHERE PLANO LIKE '%CONTROLE%' AND
PLANO NOT LIKE '%Renova%' AND
A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet') AND
(REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND
A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
add a comment |
brackets missing on OR clause:
SELECT DISTINCT REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM @A AS A
LEFT JOIN @B AS B ON
A.[NOME DPGC] = B.APARELHODPAV
WHERE PLANO LIKE '%CONTROLE%' AND
PLANO NOT LIKE '%Renova%' AND
A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet') AND
(REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND
A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
add a comment |
brackets missing on OR clause:
SELECT DISTINCT REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM @A AS A
LEFT JOIN @B AS B ON
A.[NOME DPGC] = B.APARELHODPAV
WHERE PLANO LIKE '%CONTROLE%' AND
PLANO NOT LIKE '%Renova%' AND
A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet') AND
(REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND
A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
brackets missing on OR clause:
SELECT DISTINCT REPLACE(REPLACE(A.[NOME COMERCIAL],'.',''),'&','') AS [NOME COMERCIAL] ,
ISNULL(A.[PLANO], '') AS PLANO ,
A.[Plano Foco] ,
CONVERT(DECIMAL(18,2),A.[PRECO]) AS PRECO ,
B.[FEAT_CAMERA] ,
B.[FEAT_TELA] ,
B.[FEAT_CAP_ARMAZENAMENTO] ,
B.[FEAT_PROCESSADOR] ,
B.[FEAT_MEMORIA_RAM] ,
B.[FEAT_BATERIA] ,
B.[EXTRA_INFO_1] ,
B.[EXTRA_INFO_2] ,
B.[EXTRA_INFO_3]
FROM @A AS A
LEFT JOIN @B AS B ON
A.[NOME DPGC] = B.APARELHODPAV
WHERE PLANO LIKE '%CONTROLE%' AND
PLANO NOT LIKE '%Renova%' AND
A.[PRODUTO] IN ('Smartphone', 'Blackbox 3G', 'Blackbox 4G', 'Fixo', 'Modem 3G', 'Modem 4G', 'Tablet') AND
(REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND
A.[REGIAO] = '7x'
ORDER BY PRECO,[PLANO]
answered Nov 12 at 15:26
Marta B
35118
35118
add a comment |
add a comment |
If you do not want to include Renova, do not include it in your where clause and it will be exempted from the selection. That will solve your problem.
add a comment |
If you do not want to include Renova, do not include it in your where clause and it will be exempted from the selection. That will solve your problem.
add a comment |
If you do not want to include Renova, do not include it in your where clause and it will be exempted from the selection. That will solve your problem.
If you do not want to include Renova, do not include it in your where clause and it will be exempted from the selection. That will solve your problem.
answered Nov 12 at 17:26
Ted
302
302
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265026%2fwhere-clause-with-like-and-not-like-operators-not-working%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
It's not the
(NOT) LIKE
. When you format your query (I did it for you) it's easier to spot that there's anOR
ed condition.AND
has a higher precedence thanOR
, you probably don't want that --> add parens around theOR
ed condition.AND (REPLACE(REPLACE(REPLACE(A.[NOME DPGC],'&',''),'''',''),'.','') = 'Iphone XR 64GB' OR REPLACE(REPLACE(REPLACE(B.[APARELHODPAV],'&',''),'''',''),'.','') = 'Iphone XR 64GB') AND A.[REGIAO] = '7x'
. Btw, you should always use parens when you mixAND
andOR
– dnoeth
Nov 12 at 15:19
@dnoeth dont know why you didnt make it an answer
– Juan Carlos Oropeza
Nov 12 at 15:24
LIKE and NOT LIKE could not work properly, so i'm using ISNULL
..... I dont see ISNULL anywhere– Juan Carlos Oropeza
Nov 12 at 15:25