I have a table with one of the columns being ldap info. Example value would be:
ou=FOO,ou=BAR,o =XYZ,dc=WORLD
From this I would like to extract the first string, in this case FOO.
My last attempt was:
[CODE=mysql]SELECT 1+instr(T.ldap, "=") as startpos,
instr(T.ldap,", ") as endpos,
mid(T.ldap,star tpos,endpos-startpos)
FROM myTable T where ldap like @likeStr;[/CODE]
which gives me error message:
ERROR 1054 (42S22): Unknown column 'startpos' in 'field list'
1+instr(T.ldap, "=") evaluates to the correct value -- 4 for the example ldap field value on the top
Same with instr(T.ldap,", ") -- 7 in the example
And mid(T.ldap,4,7-4) would give me the correct value -- FOO in the example
However, I can not rely on the numbers 4 and 7.
Any suggestions?
ou=FOO,ou=BAR,o =XYZ,dc=WORLD
From this I would like to extract the first string, in this case FOO.
My last attempt was:
[CODE=mysql]SELECT 1+instr(T.ldap, "=") as startpos,
instr(T.ldap,", ") as endpos,
mid(T.ldap,star tpos,endpos-startpos)
FROM myTable T where ldap like @likeStr;[/CODE]
which gives me error message:
ERROR 1054 (42S22): Unknown column 'startpos' in 'field list'
1+instr(T.ldap, "=") evaluates to the correct value -- 4 for the example ldap field value on the top
Same with instr(T.ldap,", ") -- 7 in the example
And mid(T.ldap,4,7-4) would give me the correct value -- FOO in the example
However, I can not rely on the numbers 4 and 7.
Any suggestions?
Comment