Wednesday, May 23, 2012

MySQL IndexOf and Substring example

example to select the name only
SELECT INSTR('ariel@lti', '@');
SELECT SUBSTRING('MySQL Substring',7,3);

SELECT Name, Email ,
   INSTR(Email, '@') as indx,
   SUBSTRING(Email, 1INSTR(Email, '@')-1) as wow ,
   SUBSTRING(Email, 1, 9) AS nooo
FROM supplier_contact WHERE name='No Info';

example to select the domain only
SELECT SUBSTRING(Email, INSTR(Email, '@')+1, LENGTH(Email)) AS domain, Email
FROM supplier_contact

No comments:

Post a Comment