Sunday, August 1, 2010

mysql remove hex a0, 0d etc

SELECT  TRIM(BOTH 'A0' FROM HEX(CAS)), UNHEX(TRIM(BOTH 'A0' FROM HEX(CAS))), HEX(CAS), CAS
FROM compounds
WHERE CAS REGEXP '[0-9]-[0-9]{2}-[0-9]{1}'   AND CAS LIKE '1%' AND mol_id=2100088;
         
       
161735-79-1     161735-79-1     161735-79-1 ;
SELECT * FROM compounds WHERE CAS LIKE '%157283-68-6%' ;
31 35 37 32 38 33 2D 36 38 2D 36 A00D
SELECT * FROM compounds WHERE TRIM(CAS) = '161735-79-1' ;


SELECT CAS FROM compounds WHERE TRIM(CAS) LIKE "1%" ;


UPDATE compounds
SET CAS =  UNHEX(TRIM(BOTH 'A0' FROM HEX(CAS)))
WHERE uid=21 ;

No comments:

Post a Comment