Home » SQL & PL/SQL » SQL & PL/SQL » Finding a column name of a column you know the value of.
Finding a column name of a column you know the value of. [message #2679] Tue, 06 August 2002 07:58 Go to next message
Jason Reid
Messages: 2
Registered: August 2002
Junior Member
Hi i'm writing a full text search app using Delphi 6 and the rubicon 2 set of components.The problem that I have run into is this:
I can retrieve all the information I need using the rubicon components exept the name of the field where the match occoured.Now i know i can retrieve all the column names with a query that goes something along the lines of:

SELECT COLUMN_NAME
FROM ALL_TAB_COLUMNS
WHERE OWNER = :OWNER AND TABLE_NAME = :TABLENAME
ORDER BY COLUMN_NAME

My question is , is there some way I can add to this query to specify that it must only return colunm names that have a certain value (ei my search value).
Perhaps something like:

SELECT COLUMN_NAME
FROM ALL_TAB_COLUMNS
WHERE OWNER = :OWNER AND TABLE_NAME = :TABLENAME
AND VALUE = :SEARCHVALUE
ORDER BY COLUMN_NAME

Thats just a guess but if anyone can help me out I would REALLY appreciate it...

Thanks in advance

Jason Reid
Re: Finding a column name of a column you know the value of. [message #2682 is a reply to message #2679] Tue, 06 August 2002 08:09 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
so, are u looking to display the columns of a table,
where u know only value of record and dont know, in which column it is???
or simply search the record, in all columns of a table?
Re: Finding a column name of a column you know the value of. [message #2693 is a reply to message #2679] Tue, 06 August 2002 19:33 Go to previous messageGo to next message
Raymond
Messages: 30
Registered: September 2000
Member
i would use a subquery to return the search values:
ex

select cname from tname
where cname in (select cname from tname
where cval = searchval)
and owner = blah
and...

hope this helps
Re: Finding a column name of a column you know the value of. [message #2697 is a reply to message #2693] Wed, 07 August 2002 00:22 Go to previous message
Jason Reid
Messages: 2
Registered: August 2002
Junior Member
Hi Raymond.
Thanks for your response.The problem is that i need the SYNTAX for the query, ie ... How do i tell SQL that i want column names that match a certain value.
Previous Topic: I need INITCAP to ignore apostrophes.
Next Topic: Crystal Report Support for Ref_Cursors
Goto Forum:
  


Current Time: Thu Mar 28 07:41:27 CDT 2024