免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2420 | 回复: 0
打印 上一主题 下一主题

mysql 字符串函数 INSTR [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-10-13 15:28 |只看该作者 |倒序浏览
select right('foobar-bar', length('foobar-bar')-INSTR('foobar-bar', '-'));

参考
http://translate.google.com.hk/translate?hl=zh-CN&langpair=en|zh-CN&u=http://dev.mysql.com/doc/refman/5.0/en/func-op-summary-ref.html
ABS()           Return the absolute value返回绝对值
ACOS()         Return the arc cosine返回反余弦
ADDDATE()         Add time values (intervals) to a date value添加时间值(间隔)为日期值
ADDTIME()         Add time添加时间
AES_DECRYPT()         Decrypt using AES使用AES解密
AES_ENCRYPT()         Encrypt using AES使用AES加密
AND , && AND , &&         Logical AND逻辑与
ASCII()         Return numeric value of left-most character返回数值的最左边的字符
ASIN()         Return the arc sine返回反正弦
ATAN2() , ATAN() ATAN2()函数atan() ATAN()         Return the arc tangent of the two arguments返回两个参数的反正切
ATAN()         Return the arc tangent返回的反正切
AVG()         Return the average value of the argument返回参数的平均值
BENCHMARK()         Repeatedly execute an expression重复执行一个表达式
BETWEEN ... AND ...         Check whether a value is within a range of values检查一个值是否在一个范围值
BIN()         Return a string representation of the argument返回一个参数的字符串表示
BINARY         Cast a string to a binary string铸造一个字符串二进制字符串
BIT_AND()         Return bitwise and Return位与
BIT_COUNT()         Return the number of bits that are set返回的位数设置
BIT_LENGTH()         Return length of argument in bits返回的长度以位论证
BIT_OR()         Return bitwise or Return按位或
BIT_XOR()         Return bitwise xor Return按位XOR
&         Bitwise AND按位与
~         Invert bits位反转
|         Bitwise OR按位或
^         Bitwise XOR按位异或
CASE         Case operator案例操作
CAST()         Cast a value as a certain type转换为某种类型的值
CEIL()         Return the smallest integer value not less than the argument最小整数返回值不小于参数
CEILING()         Return the smallest integer value not less than the argument最小整数返回值不小于参数
CHAR_LENGTH()         Return number of characters in argument返回参数中的字符数
CHAR()         Return the character for each integer passed返回的每个字符传递整数
CHARACTER_LENGTH()         A synonym for CHAR_LENGTH()一种CHAR_LENGTH的同义词()
CHARSET()         Return the character set of the argument返回参数的字符集
COALESCE()         Return the first non-NULL argument返回第一个非NULL参数
COERCIBILITY()         Return the collation coercibility value of the string argument返回字符串参数的整理可压缩性值
COLLATION()         Return the collation of the string argument返回字符串参数的排序规则
COMPRESS()         Return result as a binary string返回结果为一个二进制字符串
CONCAT_WS()         Return concatenate with separator返回连接具有分离器
CONCAT()         Return concatenated string返回连接字符串
CONNECTION_ID()         Return the connection ID (thread ID) for the connection返回连接ID(线程ID)为连接
CONV()         Convert numbers between different number bases不同的数字之间转换数字基地
CONVERT_TZ()         Convert from one timezone to another从一个时区转换到另一个
Convert()         Cast a value as a certain type转换为某种类型的值
COS()         Return the cosine返回余弦
COT()         Return the cotangent返回余切
COUNT(DISTINCT)         Return the count of a number of different values返回计数的不同值的数量
COUNT()         Return a count of the number of rows returned返回一个计数返回的行数
CRC32()         Compute a cyclic redundancy check value计算循环冗余校验值
CURDATE()         Return the current date返回当前的日期
CURRENT_DATE() , CURRENT_DATE CURRENT_DATE() CURRENT_DATE CURRENT_DATE         Synonyms for CURDATE()为CURDATE同义词()
CURRENT_TIME() , CURRENT_TIME CURRENT_TIME()的current_time CURRENT_TIME         Synonyms for CURTIME()为CURTIME同义词()
CURRENT_TIMESTAMP() , CURRENT_TIMESTAMP CURRENT_TIMESTAMP() CURRENT_TIMESTAMP的CURRENT_TIMESTAMP         Synonyms for NOW()同义词为NOW()
CURRENT_USER() , CURRENT_USER CURRENT_USER() CURRENT_USER CURRENT_USER         The authenticated user name and host name经过验证的用户名和主机名
CURTIME()         Return the current time返回当前时间
DATABASE()         Return the default (current) database name返回默认(当前)数据库的名称
DATE_ADD()         Add time values (intervals) to a date value添加时间值(间隔)为日期值
DATE_FORMAT()         Format date as specified指定格式的日期
DATE_SUB()         Subtract a time value (interval) from a date减去一个时间值(区间)从一个日期
DATE()         Extract the date part of a date or datetime expression提取日期或日期时间表达式的日期部分
DATEDIFF()         Subtract two dates减去两个日期
DAY()         Synonym for DAYOFMONTH()为DAYOFMONTH的同义词()
DAYNAME()         Return the name of the weekday返回名称平日
DAYOFMONTH()         Return the day of the month (0-31)返回该月(0-31)天
DAYOFWEEK()         Return the weekday index of the argument返回该参数平日指数
DAYOFYEAR()         Return the day of the year (1-366)返回该年(1-366)天
DECODE()         Decodes a string encrypted using ENCODE()使用加密字符串解码器编码()
DEFAULT()         Return the default value for a table column返回一个表列的默认值
DEGREES()         Convert radians to degrees弧度转换为度
DES_DECRYPT()         Decrypt a string解密一个字符串
DES_ENCRYPT()         Encrypt a string加密字符串
DIV         Integer division整数除法
/         Division operator除法运算符
ELT()         Return string at index number返回字符串的索引号
ENCODE()         Encode a string编码字符串
ENCRYPT()         Encrypt a string加密字符串
<=>         NULL-safe equal to operator空安全等于运营商
=         Equal operator等号操作
EXP()         Raise to the power of功率提高到了
EXPORT_SET()         Return a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off string返回一个字符串,这样在每个位值位设置,你对每一个未设置字符串和位得到的,你会得到一个字符串关闭
EXTRACT()         Extract part of a date提取部分日期
FIELD()         Return the index (position) of the first argument in the subsequent arguments返回第一个参数的索引(位置)在随后的争论
FIND_IN_SET()         Return the index position of the first argument within the second argument在第二个参数返回的第一个参数的索引位置
FLOOR()         Return the largest integer value not greater than the argument最大整数值返回不大于参数大
FORMAT()         Return a number formatted to specified number of decimal places返回一个数字格式到指定的小数位数
FOUND_ROWS()         For a SELECT with a LIMIT clause, the number of rows that would be returned were there no LIMIT clause对于有一个LIMIT子句的SELECT,该会在那里返回的行数没有限制条款
FROM_DAYS()         Convert a day number to a date天数转换为日期
FROM_UNIXTIME()         Format UNIX timestamp as a date UNIX时间戳格式为日期
GET_FORMAT()         Return a date format string返回一个字符串的日期格式
GET_LOCK()         Get a named lock获得命名的锁
>=         Greater than or equal operator大于或等于运算符
>         Greater than operator大于运营商
GREATEST()         Return the largest argument返回最大的争论
GROUP_CONCAT()         Return a concatenated string返回一个连接字符串
HEX()         Return a hexadecimal representation of a decimal or string value返回一个字符串值的十进制或十六进制表示
HOUR()         Extract the hour提取小时
IF()         If/else construct如果/ else结构
IFNULL()         Null if/else construct空的if / else结构
IN()         Check whether a value is within a set of values检查一个值是否在一个组值
INET_ATON()         Return the numeric value of an IP address返回一个IP地址的数值
INET_NTOA()         Return the IP address from a numeric value返回从一个数值的IP地址
INSERT()         Insert a substring at the specified position up to the specified number of characters插入一个子字符串在指定位置到指定的字符数
INSTR()         Return the index of the first occurrence of substring返回指数第一次出现的子串
INTERVAL()         Return the index of the argument that is less than the first argument返回参数的指数,比第一个参数少
IS_FREE_LOCK()         Checks whether the named lock is free检查是否已命名的锁是免费的
IS NOT NULL         NOT NULL value test NOT NULL的值测试
IS NOT         Test a value against a boolean试验对一个布尔值
IS NULL         NULL value test NULL值测试
IS_USED_LOCK()         Checks whether the named lock is in use.检查是否正在使用名为锁。 Return connection identifier if true.如果为true返回连接标识符。
IS         Test a value against a boolean试验对一个布尔值
ISNULL()         Test whether the argument is NULL测试是否为NULL参数
LAST_DAY         Return the last day of the month for the argument返回该月最后一天的说法
LAST_INSERT_ID()         Value of the AUTOINCREMENT column for the last INSERT价值为最后一个INSERT AUTOINCREMENT列
LCASE()         Synonym for LOWER()同义词降()
LEAST()         Return the smallest argument返回小的争执
<<         Left shift左移
LEFT()         Return the leftmost number of characters as specified返回最左边的字符数指定
LENGTH()         Return the length of a string in bytes返回一个字符串的字节长度
<=         Less than or equal operator小于或等于操作符
<         Less than operator不到运营商
LIKE         Simple pattern matching简单的模式匹配
LN()         Return the natural logarithm of the argument返回参数的自然对数
LOAD_FILE()         Load the named file加载指定的文件
LOCALTIME() , LOCALTIME LOCALTIME()本地时间LOCALTIME         Synonym for NOW()对于现在的同义词()
LOCALTIMESTAMP , LOCALTIMESTAMP() LOCALTIMESTAMP , LOCALTIMESTAMP()         Synonym for NOW()对于现在的同义词()
LOCATE()         Return the position of the first occurrence of substring返回子串的位置第一次出现
LOG10()         Return the base-10 logarithm of the argument返回基地- 10的对数的论点
LOG2()         Return the base-2 logarithm of the argument返回基地- 2对数的论点
LOG()         Return the natural logarithm of the first argument返回第一个参数的自然对数
LOWER()         Return the argument in lowercase返回参数的小写
LPAD()         Return the string argument, left-padded with the specified string返回字符串参数,左以指定字符串填充
LTRIM()         Remove leading spaces删除前导空格
MAKE_SET()         Return a set of comma-separated strings that have the corresponding bit in bits set返回一个由逗号分隔的字符串中有位设置相应的位设置
MAKEDATE()         Create a date from the year and day of year从创建之日起一年一年和一天
MAKETIME         MAKETIME() MAKETIME()
MASTER_POS_WAIT()         Block until the slave has read and applied all updates up to the specified position阻塞,直到从已经阅读并应用所有更新到指定位置
MATCH         Perform full-text search执行全文搜索
MAX()         Return the maximum value返回最大值
MD5()         Calculate MD5 checksum计算MD5校验
MICROSECOND()         Return the microseconds from argument从参数返回微秒
MID()         Return a substring starting from the specified position返回一个子字符串从指定位置开始
MIN()         Return the minimum value返回最低值
-         Minus operator负运算
MINUTE()         Return the minute from the argument返回分钟的争论
MOD()         Return the remainder返回其余
%         Modulo operator模运算符
MONTH()         Return the month from the date passed返回之日起一个月的传递
MONTHNAME()         Return the name of the month返回名称的月份
NAME_CONST()         Causes the column to have the given name原因列有名字
NOT BETWEEN ... AND ...         Check whether a value is not within a range of values检查是否有值不是值范围内
!= , <> != , <>         Not equal operator不等于操作符
NOT IN()         Check whether a value is not within a set of values检查是否有值不是在一组值
NOT LIKE         Negation of simple pattern matching否定的简单模式匹配
NOT REGEXP         Negation of REGEXP REGEXP的否定
NOT , ! NOT , !         Negates value否定价值
NOW()         Return the current date and time返回当前的日期和时间
NULLIF()         Return NULL if expr1 = expr2返回NULL如果expr1 = expr2的
OCT()         Return an octal representation of a decimal number返回一个十进制数八进制表示
OCTET_LENGTH()         A synonym for LENGTH()一个边长的同义词()
OLD_PASSWORD()         Return the value of the pre-4.1 implementation of PASSWORD返回值在4.1之前的密码实施
|| , OR || , OR         Logical OR逻辑或
ORD()         Return character code for leftmost character of the argument返回参数的最左边的字符的字符编码
PASSWORD()         Calculate and return a password string计算并返回一个密码字符串
PERIOD_ADD()         Add a period to a year-month添加到一年期一个月
PERIOD_DIFF()         Return the number of months between periods返回数月间期
PI()         Return the value of pi返回值的圆周率
+         Addition operator加法运算
POSITION()         A synonym for LOCATE()为找到一个同义词()
POW()         Return the argument raised to the specified power返回参数提高到指定电源
POWER()         Return the argument raised to the specified power返回参数提高到指定电源
PROCEDURE ANALYSE()         Analyze the results of a query分析一个查询的结果
QUARTER()         Return the quarter from a date argument从一季度返回日期参数
QUOTE()         Escape the argument for use in an SQL statement逃离用于在SQL语句的参数
RADIANS()         Return argument converted to radians返回参数转换为弧度
RAND()         Return a random floating-point value返回一个随机浮点值
REGEXP         Pattern matching using regular expressions使用正则表达式模式匹配
RELEASE_LOCK()         Releases the named lock释放名为锁
REPEAT()         Repeat a string the specified number of times重复一个字符串中指定的次数
REPLACE()         Replace occurrences of a specified string指定的字符串替换匹配
REVERSE()         Reverse the characters in a string反向字符串中的字符
>>         Right shift右移
RIGHT()         Return the specified rightmost number of characters返回指定最右边的字符数
RLIKE         Synonym for REGEXP REGEXP的同义词
ROUND()         Round the argument回合的争论
ROW_COUNT()         The number of rows updated更新的行数
RPAD()         Append string the specified number of times追加字符串中指定的次数
RTRIM()         Remove trailing spaces删除尾随空格
SCHEMA()         A synonym for DATABASE()为数据库的同义词()
SEC_TO_TIME()         Converts seconds to 'HH:MM:SS' format转换秒'为HH:MM:SS'格式
SECOND()         Return the second (0-59)返回第二(0-59)
SESSION_USER()         Synonym for USER()对于用户的同义词()
SHA1() , SHA() SHA1()沙() SHA()         Calculate an SHA-1 160-bit checksum计算出的SHA - 1 160位校验
SIGN()         Return the sign of the argument返回参数的符号
SIN()         Return the sine of the argument返回正弦参数
SLEEP()         Sleep for a number of seconds睡眠指定的秒数
SOUNDEX()         Return a soundex string返回一个字符串的soundex
SOUNDS LIKE         Compare sounds听起来比较
SPACE()         Return a string of the specified number of spaces返回一个字符串指定数目的空格
SQRT()         Return the square root of the argument返回该参数的平方根
STD()         Return the population standard deviation返回总体标准差
STDDEV_POP()         Return the population standard deviation返回总体标准差
STDDEV_SAMP()         Return the sample standard deviation返回样本标准偏差
STDDEV()         Return the population standard deviation返回总体标准差
STR_TO_DATE()         Convert a string to a date将字符串转换为日期
STRCMP()         Compare two strings比较两个字符串
SUBDATE()         A synonym for DATE_SUB() when invoked with three arguments一种DATE_SUB的同义词()调用时,三个参数
SUBSTR()         Return the substring as specified返回指定的子串
SUBSTRING_INDEX()         Return a substring from a string before the specified number of occurrences of the delimiter回归前出现的分隔符指定数目的从字符串的子串
SUBSTRING()         Return the substring as specified返回指定的子串
SUBTIME()         Subtract times减去倍
SUM()         Return the sum返回总和
SYSDATE()         Return the time at which the function executes返回时间执行该函数
SYSTEM_USER()         Synonym for USER()对于用户的同义词()
TAN()         Return the tangent of the argument返回参数的正切
TIME_FORMAT()         Format as time随着时间的格式
TIME_TO_SEC()         Return the argument converted to seconds Return参数转换为秒
TIME()         Extract the time portion of the expression passed提取所传递的表达时间的部分
TIMEDIFF()         Subtract time减去时间
*         Times operator时代运营商
TIMESTAMP()         With a single argument, this function returns the date or datetime expression; with two arguments, the sum of the arguments带一个参数,这个函数返回的日期或日期时间表达式;带两个参数,该参数的总和
TIMESTAMPADD()         Add an interval to a datetime expression添加间隔datetime表达式
TIMESTAMPDIFF()         Subtract an interval from a datetime expression减去一个时间间隔从datetime表达式
TO_DAYS()         Return the date argument converted to days返回日期参数转换为天
TRIM()         Remove leading and trailing spaces删除前导和尾随空格
TRUNCATE()         Truncate to specified number of decimal places截断到指定的小数位数
UCASE()         Synonym for UPPER()上段的同义词()
-         Change the sign of the argument改变参数的符号
UNCOMPRESS()         Uncompress a string compressed压缩解压字符串
UNCOMPRESSED_LENGTH()         Return the length of a string before compression返回字符串的长度压缩前
UNHEX()         Convert each pair of hexadecimal digits to a character每个十六进制数字转换为字符一双
UNIX_TIMESTAMP()         Return a UNIX timestamp返回一个UNIX时间戳
UPPER()         Convert to uppercase转换为大写
USER()         The user name and host name provided by the client用户名和主机名由客户提供
UTC_DATE()         Return the current UTC date返回当前UTC日期
UTC_TIME()         Return the current UTC time返回当前的UTC时间
UTC_TIMESTAMP()         Return the current UTC date and time返回当前UTC日期和时间
UUID()         Return a Universal Unique Identifier (UUID)返回一个通用唯一标识符(UUID)
VALUES()         Defines the values to be used during an INSERT定义的值是在插入过程中使用
VAR_POP()         Return the population standard variance返回总体标准方差
VAR_SAMP()         Return the sample variance返回样本方差
VARIANCE()         Return the population standard variance返回总体标准方差
VERSION()         Returns a string that indicates the MySQL server version返回一个字符串,表示MySQL服务器版本
WEEK()         Return the week number返回周数
WEEKDAY()         Return the weekday index返回平日指数
WEEKOFYEAR()         Return the calendar week of the date (0-53)返回的日期(0-53)日历周
XOR         Logical XOR逻辑异或
YEAR()         Return the year返回年
YEARWEEK()         Return the year and week返回年和星期


http://translate.google.com.hk/translate?hl=zh-CN&langpair=en|zh-CN&u=http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

INSTR( str , substr )

Returns the position of the first occurrence of substring substr in string str .返回子字符串的位置发生的第一substr的字符串str 。 This is the same as the two-argument form of LOCATE() , except that the order of the arguments is reversed.这是相同的两个参数形式的LOCATE()但该参数的顺序是相反的。

mysql> SELECT INSTR('foobarbar', 'bar'); MySQL的“ SELECT INSTR('foobarbar', 'bar');
        -> 4 - >“4
mysql> SELECT INSTR('xbar', 'foobar'); MySQL的“ SELECT INSTR('xbar', 'foobar');
        -> 0 - “0

This function is multi-byte safe, and is case sensitive only if at least one argument is a binary string.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP