| QUERY (2 Merged) [message #563415] |
Mon, 13 August 2012 10:56  |
 |
vaibhav15211
Messages: 13 Registered: August 2012 Location: Hyderabad
|
Junior Member |
|
|
I have a table with multiple columns.
For the first two columns: column1 and column2, If column1 has a value then column2 is NULL and if column2 has a value then column1 is NULL.
I am receiving one value from a JAVA interface which has both column1 and column2 as option,user selects one.
Now if the option selected is of type column1,I have to select corresponding row and vice versa. Please suggest a solution.
|
|
|
|
|
|
|
|
| Re: QUERY (2 Merged) [message #563423 is a reply to message #563421] |
Mon, 13 August 2012 11:40   |
Solomon Yakobson
Messages: 1398 Registered: January 2010
|
Senior Member |
|
|
Michel Cadot wrote on Mon, 13 August 2012 12:33select * from mytable where column1||column2 = value
That would return rows where column1 = value and rows where column2 = value. I think it should be something like
select *
from mytable
where (
:column_type = 1
and
column1 = :value
)
or column2 = :value
/
SY.
[Updated on: Mon, 13 August 2012 11:41] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: QUERY (2 Merged) [message #563553 is a reply to message #563516] |
Tue, 14 August 2012 13:41   |
Solomon Yakobson
Messages: 1398 Registered: January 2010
|
Senior Member |
|
|
And what if you have:
COLUMN1 COLUMN2 COLUMN3 COLUMN4
------- ------- ------- -------
A US English US
A AU German AU
and you receive 'A' as value from JAVA interface?
SY.
|
|
|
|
|
|
| Re: QUERY (2 Merged) [message #563577 is a reply to message #563576] |
Wed, 15 August 2012 05:19  |
Solomon Yakobson
Messages: 1398 Registered: January 2010
|
Senior Member |
|
|
vaibhav15211 wrote on Wed, 15 August 2012 05:38Thanks Flyby for the solutions.
Solomon:both column1 and column2 will have different and unique values so that is not a problem 
This doesn't make much sense. You said: if column1 is not null then column2 is null and vice versa. No you added if some row has column1 = 'A' there can't be a row with column2 = 'A'. Based on that there is absolutely no need for two columns. All you need is one column with value of nvl(column1,column2).
SY.
|
|
|
|