SQL - How to filter only domains containing "Hotmail.com";

Asked

Viewed 82 times

-4

Write a select that meets the criteria below:

1° Filter only domains containing "Hotmail.com";

2° Consider the contracts below; 683679 705126 715651

TABLE

SELECT * FROM FDADOS_RE170(3,3) limit 12
carteira; tn; contrato; cpf; tipo_contato; contato; classificacao; origem; score;

3; 1; 710195; 02714662196; Email [email protected]; 1 - Excelente; M; 0

3; 1; 710195; 02714662196; Email [email protected] ;1 - Excelente M; 0

3; 1; 710195; 02714662196; Email [email protected]; 1 - Excelente; M; 0

3; 1; 710195; 02714662196; Email [email protected] 1 - Excelente; M; 0

3; 1; 710195; 02714662196; Email [email protected] ;9 - Indefinido O; 0

sql
  • What is the question then? What part of the filter do you not understand? You know the clause LIKE validation?

  • Welcome! Use the operator like, will look like this ... contato LIKE '%hotmail.com' Read this answer: What is the real difference between the operator '=' and LIKE?

  • Friend you could leave the code better for viewing?

  • The doubt is to make a select that brings me 1° Filter only domains that contains "Hotmail.com"; 2° Consider the contracts below; 683679 705126 715651

  • 1

    Please do not duplicate questions. If the previous question was not well received, concentrate your efforts there. Edit it and follow the instructions given in the comments, and if she agrees it will be reopened

  • Not knowing the name of the table where we will work will be difficult, the numbers of contracts will be entered manually? Do: select * from SUA_TABELA where (contrato = (VARIAVEL_COM_NR_DOS_CONTRATOS)) and contato like '%hotmail.com'

  • Thank you Luiz Augusto

  • 3

    Not knowing how to do is no doubt. Doubts only arise after trying to do or study how to do.

Show 3 more comments

1 answer

-2

Will stay like this:

SELECT * FROM 'TABELA_NOME' 
where 
(contrato = 683679 
OR contrato = 705126 
OR contrato = 715651)
LIKE '%@hotmail.com%'

in TABELA_NOME is the name of your table.

  • 2

    Accepted [email protected], false positive for the purposes of the question

  • @Jeffersonquesado check the statement again. Filter only domains that contain "Hotmail.com". shotmail.com contains Hotmail.com, agrees with the statement. However, [email protected] also contains "Hotmail.com" and would not be displayed with that answer.

  • then put@and%at the end, then anything that has @Hotmail.com will be displayed :'%@Hotmail.com%'

Browser other questions tagged

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