Domanda

C'è un modo per selezionare le righe della tabella del database in cui un determinato valore è una certa lunghezza, ad esempio, meno di 5 caratteri?

In PHP che sarebbe strlen .

C'è qualcosa di simile in mysql?

È stato utile?

Soluzione

SELECT * FROM table_name WHERE CHAR_LENGTH(column_name) < 5

Altri suggerimenti

LENGTH("my_string") Return the length of a string in bytes

SELECT * FROM table_name WHERE LENGTH(column_name) < 5

Keep in mind that characters can be made up of multiple bytes like those in UTF-8.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top