Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    SQL select dei primi 30 caratteri di un record

    come faccio a selezionare e a far stampare solo i primi 30 caratteri di un record?

  2. #2
    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.



    mysql> SELECT SUBSTRING('Quadratically',5);
    -> 'ratically'
    mysql> SELECT SUBSTRING('foobarbar' FROM 4);
    -> 'barbar'
    mysql> SELECT SUBSTRING('Quadratically',5,6);
    -> 'ratica'


    This function is multi-byte safe.



    SUBSTRING_INDEX(str,delim,count)

    Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned.



    mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
    -> 'www.mysql'
    mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);
    -> 'mysql.com'


    This function is multi-byte safe.


    se non vuoi troncare le parole ti consiglio la seconda usando come parametri uno spazio ' ' e il numero di parole che vuoi visualizzare.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.