locate

Description

Syntax

‘INT LOCATION (WARCHAR substrate, WARCHAR str [, INT pos]]‘

Returns where substr appears in str (counting from 1). If the third parameter POS is specified, the position where substr appears is found from the string where STR starts with POS subscript. If not found, return 0

example

  1. mysql> SELECT LOCATE('bar', 'foobarbar');
  2. +----------------------------+
  3. | locate('bar', 'foobarbar') |
  4. +----------------------------+
  5. | 4 |
  6. +----------------------------+
  7. mysql> SELECT LOCATE('xbar', 'foobar');
  8. +--------------------------+
  9. | locate('xbar', 'foobar') |
  10. +--------------------------+
  11. | 0 |
  12. +--------------------------+
  13. mysql > SELECT LOCATE ('bar','foobarbar', 5);
  14. +-------------------------------+
  15. Location ('bar','foobarbar', 5)'124s;
  16. +-------------------------------+
  17. | 7 |
  18. +-------------------------------+

keyword LOCATE