Mysql – Consulta LIKE


Iniciando em Mysql, veja como é simples trabalhar com consultas usando LIKE.

LIKE ‘__a%’
Vai ser buscado todos os itens que tenham a letra a na quarta posição da palavra.

LIKE ‘%a’
Palavras terminadas em a.

LIKE ‘a%’
Palavras começadas em a.

LIKE ‘a%b%c’
Palavra deve começar com a, ter no meio b e terminar com c.

NOT LIKE ‘%@%’
not like é retornado todos os dados que não tenham o valor definido nele, no caso, retorna tudo que não tenha @

campo LIKE ‘%@%’
Retorna todos os dados que tenham o valor definido nele, no caso, retorna tudo que tenha @


SELECT * FROM `tb_tabela` WHERE campo LIKE "%a%"

7 Comments (+add yours?)

  1. Christian Louboutin
    jun 12, 2010 @ 06:05:40

    Good job. I’m definitely going to bookmark you!

  2. wholesale sunglasses
    jun 14, 2010 @ 06:53:21

    One again, your article is very nice

  3. Louboutin shoes
    jun 16, 2010 @ 17:58:47

    good share, great article, very usefull for us…thank you

  4. Bad credit loan
    jul 27, 2010 @ 16:15:33

    really appreciate YOU — thanks a lot!

  5. wholesale sunglasses
    jul 28, 2010 @ 17:51:31

    Yes… i also really like to visit new place, your idea is good.

  6. Betting Euro 2012 Promotional Code
    dez 18, 2010 @ 02:50:08

    I have read a few of the blog posts on your web site today, and I truly like your style of blogging. I tag it to my bookmark web site list and will be checking back soon. Please visit my web site as well and let me know your opinion.

  7. David
    mar 31, 2011 @ 01:04:55

    Nossa cara, me ajudo muito, valeu ;D

Leave a Reply