0

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 with the tag like but how can I take the society and site when the like string occurs?????

Please help me

4
  • We need to see your table structures, and maybe some data. Also, do you wish to limit the result set based on the criteria above, is that all AND or OR conditions? Commented Jan 20, 2010 at 14:28
  • That looks like an LDAP query. Perhaps your data comes from an LDAP backend? Commented Jan 20, 2010 at 14:31
  • is it microsoft sql server or mysql? i don't see it, or is it just me? Commented Jan 20, 2010 at 14:33
  • yes it's an ldap query, but the ldap data now is in a mssql db Commented Jan 21, 2010 at 8:21

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Normalisation is the best way to do it.
Normalize the minimum... maybe just break out the 'OU' column.
1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.