sql - Compare two rows in AND condition -


just having problem using , operator in sql returns 0 result set.

i have following table structure:

idcompany, cloudid, cloudkey, idsearchfield, type, uservalue

now execute following statement:

select *  filter_view       (idsearchfield = 4 , compareresearch(uservalue,200) = true)      , (idsearchfield = 6 , compareresearch(uservalue,1) = true) 

compareresearch ist function casts uservalue , compares other value , returns true if value equal or greater. uservalue stored string (that's decision made 6 years ago)

okay, 0 resultset because both criterias in braces () , combined , 1 row can have 1 idsearchfield , therefor 1 of criterias won't match.

how around this? need , comparison, won't work out way.

i hope problem obvious :-)

if you've recognised both conditions can't ever both true, in way can , comparison correct one?

select *   filter_view   (idsearchfield = 4 , compareresearch(uservalue,200) = true)     or (idsearchfield = 6 , compareresearch(uservalue,1) = true) 

this return 2 rows (or more). or looking way correlate these 2 rows appear single row?


okay, making tonne of assumptions, because haven't included enough information in question.

filter_view returns number of columns, 1 of form of record identifier (lets call id). includes aforementioned idsearchfield , uservalue columns.

what want find id values, 1 row of filter_view has idsearchfield = 4 , compareresearch(uservalue,200) = true , row of filter_view has idsearchfield = 6 , compareresearch(uservalue,1) = true

the general term "relational division". in simple case, , assuming id/idsearchfield unique in view, can answer with:

select id,count(*)   filter_view   (idsearchfield = 4 , compareresearch(uservalue,200) = true)     or (idsearchfield = 6 , compareresearch(uservalue,1) = true)  group id  having count(*) = 2 

if doesn't answer question, you're going have add more info question, including sample data, , expected results.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -