Ir para conteúdo
Fórum Script Brasil
  • 0

Consulta Caracterizada


Guest CoLuNa

Pergunta

Bom dia, quero saber como eu posso fazer em uma consulta pegar certos caracteres de um registro .. por exemplo ...

Eu tenho um campo chamado "Titulo" que possui uma registro "PARALELEPIPEDO"

eu quero fazer uma consulta e pegar so os terceiro quarto quinto e sexto caracteres dessa paralavra

no caso seria os caracteres "RALE" da palavra "PARALELEPIPEDO"

Obrigado!

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

MySQL 5.0 Reference Manual

SUBSTRING(str,pos), SUBSTRING(str FROM pos), SUBSTRING(str,pos,len), SUBSTRING(str FROM pos FOR len)

The forms without a len argument return a substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at position pos. The forms that use FROM are standard SQL syntax. It is also possible to use a negative value for pos. In this case, the beginning of the substring is pos characters from the end of the string, rather than the beginning. A negative value may be used for pos in any of the forms of this function.

mysql> SELECT SUBSTRING('Quadratically',5);

-> 'ratically'

mysql> SELECT SUBSTRING('foobarbar' FROM 4);

-> 'barbar'

mysql> SELECT SUBSTRING('Quadratically',5,6);

-> 'ratica'

mysql> SELECT SUBSTRING('Sakila', -3);

-> 'ila'

mysql> SELECT SUBSTRING('Sakila', -5, 3);

-> 'aqui'

mysql> SELECT SUBSTRING('Sakila' FROM -4 FOR 2);

-> 'que'

This function is multi-byte safe.

If len is less than 1, the result is the empty string.

SUBSTR() is a synonym for SUBSTRING().

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...