Hi Tristan, If it's not too late to change the table structure, I'd agree with Sheila - you'd be much better off having a two-column table of user_id and department.
Even better, have the departments as a table, and just use the dept_id in the 'interactions' table. This means you've got a simple list of departments, and the interactions table is more efficient. Something like: table department: +-----+-----------------+ | id | name | +-----+-----------------+ | 1 | Accounts | | 2 | HR | | 3 | Support | | 4 | Marketing | +-----+-----------------+ table interactions: +-----+----------+----------+ | id | user_id | dept_id | +-----+----------+----------+ | 1 | 23 | 1 | | 2 | 17 | 2 | | 3 | 17 | 3 | | 4 | 19 | 1 | | 5 | 4 | 4 | +-----+----------+----------+ As Sheila said, this interactions table could be extended to hold the timestamp of each record, and any other info required. You could then do simple queries to get the info you need. For example, to get the department(s) a user has previously interacted with, SELECT department.name FROM interactions, departments WHERE interactions.user_id = 17 AND departments.id = interactions.dept_id You have the ability to easily get other info too, like the number of times a user has interacted with each department, how many interactions each department has had in total, etc etc, and it'll be nice and efficient. (However, rudy will probably jump in here and suggest another way to do this which would be 10 times more efficient and better DB design <g>) Cheers Dave P On Wednesday 06 April 2005 14:00, [EMAIL PROTECTED] wrote: > I need to search an entire table for a value, and then report back what > field it was found in... how on earth do I do that? > I've a list of departments, as field names. > whenever a user interacts with that Dpet, I wanna add thier id No to the > appropriate field. > > so I'll be left with a table that looks like this: > > ======================================= > > > > | Accounts | HR | Support | Marketing | > > > > --------------------------------------- > > > > | 23 | | | | > > | > > | | 17 | | | > > | | > > | | | 17 | | > > | > > | 19 | | | | > > | > > | | | | 4 | > > > > ======================================= > > So User 17 has dealt with HR and Support, and user 23 has dealt with only > Accounts. > So I wanna input an user ID no, and then get told what Dpets have been > accessed... > > I need to learn this, as I know it's simple, but I've never had to do it > before! > > Tris.... > > ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or use the web interface http://e-newsletters.internet.com/discussionlists.html/ Send Your Posts To: [email protected] To change subscription settings, add a password or view the web interface: http://intm-dl.sparklist.com/read/?forum=wdvltalk ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
