Hi,

You could do something like this:


SELECT 'Accounts' as department, Accounts as id FROM mytable WHERE Accounts
IS NOT NULL
UNION ALL       
SELECT 'Human Resources' as department, HR as id FROM mytable WHERE HR IS
NOT NULL
UNION ALL       
SELECT 'Support' as department, Support as id FROM mytable WHERE Support IS
NOT NULL
UNION ALL       
SELECT 'Marketing' as department, Marketing as id FROM mytable WHERE
Marketing IS NOT NULL


Replace "mytable" with your tablename. 

I know it works on Oracle and I've just tested in on MySql and that works
good too. The query above returned this:

department      | id 
----------------|----
Accounts        | 23 
Accounts        | 19 
Human Resources | 17 
Support         | 17 
Marketing       |  4 

Jos


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 14:52
To: php-db@lists.php.net
Subject: [PHP-DB] find a value in entire table...


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....

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to