开发者

Query sql on string

I have a db with users that have all this record .

I would like to do a query on a data like

CN=aaa, OU=Domain,OU=User, OU=bbbbbb,OU=Department, OU=cccc, OU=AUTO, DC=dddddd, DC=com

and I need to group all users by the same ou=department.

How can I do the select with the substring to search a department??

My idea for the solution is to create another table that is like this:

---------------------------------------------------
ldapstring                           | society | site
---------------------------------------------------
"CN=aaa, OU=Domain,OU=User, OU=bbbbbb,OU=Department, OU=cccc, OU=AUTO, DC=dddddd, DC=com" | societyName1 | societySite1

and my idea is to compare the string with these on the new table w开发者_如何学编程ith the tag like but how can I take the society and site when the like string occurs?????

Please help me


You could always do ColumnName LIKE '%OU=Department%'.

Regardless, I think this needs to be normalized into a better table, if possible. Multivalue columns should be avoided as much as possible.

IF you aren't dealing with a database, the next best thing would be a regular expression.


Maybe you should look into MySQL regular expressions. I, myself, have never used it, but just wanted to suggest it :-)

http://dev.mysql.com/doc/refman/5.1/en/regexp.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜