Mysql string Functions
Download 369.29 Kb.
|
MySQL String Functions
FORMAT()Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part. Syntax : FORMAT(X,D) Example : SELECT FORMAT(12332.123456, 4); Output : 12,332.1235 Example : SELECT FORMAT(12332.1,4); Output : 12,332.1000 Example : SELECT FORMAT(12332.2,0); Output : 12,332 HEX()MySQL HEX() returns a string representation of hexadecimal value of a decimal or string value specified as argument. If the argument is a string, each character in the argument is converted to two hexadecimal digits. If the argument is decimal, the function returns a hexadecimal string representation of the argument , and treated as a longlong(BIGINT) number. Syntax : HEX(str), HEX(N) Example : SELECT HEX(157); Output : 9D INSERT()Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string. Replaces the rest of the string from position pos if len is not within the length of the rest of the string. Syntax : INSERT(str,pos,len,newstr) Example : SELECT INSERT('Originalstring', 4, 5, ' insert '); Output : Ori insert string Example : SELECT INSERT('Originalstring', -3, 5, ' insert '); Output : Originalstring INSTR()MySQL INSTR() takes a string and a substring of it as arguments, and returns an integer which indicates the position of the first occurrence of the substring within the string Syntax : INSTR(str,substr) Example : SELECT INSTR('myteststring','st'); Output : 5 Download 369.29 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling