string-length

SQL SELECT everything after a certain character

限于喜欢 提交于 2019-12-03 05:35:55
问题 I need to extract everything after the last '=' (http://www.domain.com?query=blablabla - > blablabla) but this query returns the entire strings. Where did I go wrong in here: SELECT RIGHT(supplier_reference, CHAR_LENGTH(supplier_reference) - SUBSTRING('=', supplier_reference)) FROM ps_product 回答1: select SUBSTRING_INDEX(supplier_reference,'=',-1) from ps_product; Please use http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php for further reference. 回答2: Try this

Why does std::string(“\\x00”) report length of 0?

泪湿孤枕 提交于 2019-12-03 05:27:15
I have a function which needs to encode strings, which needs to be able to accept 0x00 as a valid 'byte'. My program needs to check the length of the string, however if I pass in "\x00" to std::string the length() method returns 0. How can I get the actual length even if the string is a single null character? You're passing in an empty string. Use std::string(1, '\0') instead. Or std::string{ '\0' } (thanks, @zett42) std::string is perfectly capable of storing nulls. However, you have to be wary, as const char* is not, and you very briefly construct a const char* , from which you create the

Retrieve the maximum length of a VARCHAR column in SQL Server

末鹿安然 提交于 2019-12-03 03:23:26
问题 I want to find the longest VARCHAR in a specific column of a SQL Server table. Here's an example: ID = INT IDENTITY DESC = VARCHAR(5000) ID | Desc ---|----- 1 | a 2 | aaa 3 | aa What's the SQL to return 3? Since the longest value is 3 characters? 回答1: Use the built-in functions for length and max on the description column: SELECT MAX(LEN(DESC)) FROM table_name; Note that if your table is very large, there can be performance issues. 回答2: for mysql its length not len SELECT MAX(LENGTH(Desc))

Split string to two, will have almost same length

女生的网名这么多〃 提交于 2019-12-02 20:04:54
问题 I have string: "This is a sample string", and I need to split it to 2 strings, without break the words, and that the two strings will have the closest length, so the result will be: ["This is a", "sample string"]. Another e.x.: "Gorge is nice" => ["Gorge", "is nice"] Also it will be nice, if the function can get as param the number of elements that I will get as result. Thanks for the help! 回答1: You can use indexOf with the second parameter as the half of the length of the string. By this,

Reading a character string of unknown length

跟風遠走 提交于 2019-12-02 19:40:06
I have been tasked with writing a Fortran 95 program that will read character input from a file, and then (to start with) simply spit it back out again. The tricky part is that these lines of input are of varying length (no maximum length given) and there can be any number of lines within the file. I've used do read( 1, *, iostat = IO ) DNA ! reads to EOF -- GOOD!! if ( IO < 0 ) exit ! if EOF is reached, exit do I = I + 1 NumRec = I ! used later for total no. of records allocate( Seq(I) ) Seq(I) = DNA print*, I, Seq(I) X = Len_Trim( Seq(I) ) ! length of individual sequence print*, 'Sequence

C# String.Length from Microsoft Documentation

我与影子孤独终老i 提交于 2019-12-02 17:49:00
问题 Microsoft documentation states that this code will return 7 characters The Length property returns the number of Char objects in this instance, not the number of Unicode characters. string characters = "abc\u0000def"; Console.WriteLine(characters.Length); // Displays 7 I will need a function to return as result 12 because there are 12 different characters. Which function I may use? 回答1: You would have to prevent the interpretation of the literal by the compiler. This can be done with the @

Retrieve the maximum length of a VARCHAR column in SQL Server

ε祈祈猫儿з 提交于 2019-12-02 17:22:33
I want to find the longest VARCHAR in a specific column of a SQL Server table. Here's an example: ID = INT IDENTITY DESC = VARCHAR(5000) ID | Desc ---|----- 1 | a 2 | aaa 3 | aa What's the SQL to return 3? Since the longest value is 3 characters? aweis Use the built-in functions for length and max on the description column: SELECT MAX(LEN(DESC)) FROM table_name; Note that if your table is very large, there can be performance issues. for mysql its length not len SELECT MAX(LENGTH(Desc)) FROM table_name Watch out!! If there's spaces they will not be considered by the LEN method in T-SQL. Don't

C# String.Length from Microsoft Documentation

谁说我不能喝 提交于 2019-12-02 08:49:59
Microsoft documentation states that this code will return 7 characters The Length property returns the number of Char objects in this instance, not the number of Unicode characters. string characters = "abc\u0000def"; Console.WriteLine(characters.Length); // Displays 7 I will need a function to return as result 12 because there are 12 different characters. Which function I may use? You would have to prevent the interpretation of the literal by the compiler. This can be done with the @ prefix, like this: var characters = @"abc\u0000def"; The Length property of this string will then return 12,

How to remove a row from pandas dataframe based on the length of the column values?

混江龙づ霸主 提交于 2019-12-01 14:52:21
问题 In the following pandas.DataFframe : df = alfa beta ceta a,b,c c,d,e g,e,h a,b d,e,f g,h,k j,k c,k,l f,k,n How to drop the rows in which the column values for alfa has more than 2 elements? This can be done using the length function, I know but not finding a specific answer. df = df[['alfa'].str.split(',').map(len) < 3] 回答1: You can do that test to each row in turn using pandas.DataFrame.apply() print(df[df['alfa'].apply(lambda x: len(x.split(',')) < 3)]) Gives: alfa beta ceta 1 a,b d,e,f g,h

concatenation and max length of string in VBA, access

社会主义新天地 提交于 2019-12-01 14:07:08
I've had severas problems with strings in access-vba. The thing is, access (sometimes) limit the string's length to about 255 characters. However, depending on HOW the string was built, it may be able to grow bigger then 255 chars. There's an example of WORKING code : Dim strReq as String strReq = "SELECT exampleField1, exampleField2, exampleField3, exampleField4, exampleField5 " strReq = strRec & ", exampleField6, exampleField7, exampleField8, .... [etc. insert many fields, you get it]" strReq = strReq & " FROM myTable INNER JOIN Tbl2 ON ...[many JOINs as well]" And so on, I often work with