dbTalk Databases Forums  

Soft seeking

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss Soft seeking in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Winanjaya
 
Posts: n/a

Default Soft seeking - 04-06-2006 , 06:02 AM






Dear All,

I had this records below:

ACode
80
81
817
8171
82

The parameter variable value is '817145779' what is the SQL
statement for getting '8171'

please help

Thanks a lot in advance & Regards
Winanjaya

Reply With Quote
  #2  
Old   
Sybase newsgroups
 
Posts: n/a

Default Re: Soft seeking - 04-06-2006 , 08:37 AM






In article <4434e753.1a82.1681692777 (AT) sybase (DOT) com>, Winanjaya says...
Quote:
Dear All,

I had this records below:

ACode
80
81
817
8171
82

The parameter variable value is '817145779' what is the SQL
statement for getting '8171'
We need a lot more information to help you, especially what is the
criteria which decide that 8171 is the proper result?


Quote:
please help

Thanks a lot in advance & Regards
Winanjaya

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).


Reply With Quote
  #3  
Old   
winanjaya
 
Posts: n/a

Default Re: Soft seeking - 04-06-2006 , 12:46 PM



Quote:
In article <4434e753.1a82.1681692777 (AT) sybase (DOT) com>,
Winanjaya says... Dear All,

I had this records below:

ACode
80
81
817
8171
82

The parameter variable value is '817145779' what is the
SQL statement for getting '8171'

We need a lot more information to help you, especially
what is the criteria which decide that 8171 is the proper
result?

yes, 8171 is the proper result, because I am soft seeking
'817145779' and '8171' has the most accurate pattern .. as
you see in this record list below:

Quote:
ACode
80
81
817
8171 ---> this is the most accurate pattern for
817145779
82
hopefully you understand what I need ..

Thanks a lot in advance

Regards
Winanjaya


Reply With Quote
  #4  
Old   
Rob Waywell
 
Posts: n/a

Default Re: Soft seeking - 04-06-2006 , 04:39 PM



Given what you are asking, the solution would be a sort procedure iterating
through your row values to find the one that is the "most" like the
parameter value you are comparing to.

What are you trying to accomplish?
Usually the functionality goes the other way, for example in a lookup
list box.
--
-----------------------------------------------
Robert Waywell
Sybase Adaptive Server Anywhere Developer - Version 8
Sybase Certified Professional

Sybase's iAnywhere Solutions

Please respond ONLY to newsgroup

EBF's and Patches: http://downloads.sybase.com
choose SQL Anywhere Studio >> change 'time frame' to all

To Submit Bug Reports:
http://case-express.sybase.com/cx/cx...c?CASETYPE=Bug

SQL Anywhere Studio Supported Platforms and Support Status
http://my.sybase.com/detail?id=1002288

<winanjaya> wrote

Quote:
In article <4434e753.1a82.1681692777 (AT) sybase (DOT) com>,
Winanjaya says... Dear All,

I had this records below:

ACode
80
81
817
8171
82

The parameter variable value is '817145779' what is the
SQL statement for getting '8171'

We need a lot more information to help you, especially
what is the criteria which decide that 8171 is the proper
result?

yes, 8171 is the proper result, because I am soft seeking
'817145779' and '8171' has the most accurate pattern .. as
you see in this record list below:

ACode
80
81
817
8171 ---> this is the most accurate pattern for
817145779
82

hopefully you understand what I need ..

Thanks a lot in advance

Regards
Winanjaya



Reply With Quote
  #5  
Old   
Sybase newsgroups
 
Posts: n/a

Default Re: Soft seeking - 04-06-2006 , 04:50 PM



If I understand what you need, take a look at the LIKE function.


In article <4435357c.71ea.1681692777 (AT) sybase (DOT) com>, winanjaya says...
Quote:
In article <4434e753.1a82.1681692777 (AT) sybase (DOT) com>,
Winanjaya says... Dear All,

I had this records below:

ACode
80
81
817
8171
82

The parameter variable value is '817145779' what is the
SQL statement for getting '8171'

We need a lot more information to help you, especially
what is the criteria which decide that 8171 is the proper
result?

yes, 8171 is the proper result, because I am soft seeking
'817145779' and '8171' has the most accurate pattern .. as
you see in this record list below:

ACode
80
81
817
8171 ---> this is the most accurate pattern for
817145779
82

hopefully you understand what I need ..

Thanks a lot in advance

Regards
Winanjaya

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).


Reply With Quote
  #6  
Old   
M. Searer
 
Posts: n/a

Default Re: Soft seeking - 04-07-2006 , 12:04 PM



I did something kinda similar once - converting from Foxpro to a relational
database and users wanted to list of stuff above and below what the entered.
Not because it was useful, but because that is the way it worked before.....

Anyway, you could do the following in a procedure:

Do a like and append a '%' to the parm.
If you get zero rows, remove one character from the end and try again.
Keep going in a loop until you get at least one row that matches the like.


Without using a procedure, you may also be able to do a like to get the max
record that matches the parm
assuming Acode is your column name this may work:

select max(Acode)
where Acode||'%' like arm (may need to be switched around to arm like
Acode||'%' ).

I haven't tried this specifically so I'm not sure if it works.



<winanjaya> wrote

Quote:
In article <4434e753.1a82.1681692777 (AT) sybase (DOT) com>,
Winanjaya says... Dear All,

I had this records below:

ACode
80
81
817
8171
82

The parameter variable value is '817145779' what is the
SQL statement for getting '8171'

We need a lot more information to help you, especially
what is the criteria which decide that 8171 is the proper
result?

yes, 8171 is the proper result, because I am soft seeking
'817145779' and '8171' has the most accurate pattern .. as
you see in this record list below:

ACode
80
81
817
8171 ---> this is the most accurate pattern for
817145779
82

hopefully you understand what I need ..

Thanks a lot in advance

Regards
Winanjaya



Reply With Quote
  #7  
Old   
Winanjaya
 
Posts: n/a

Default Re: Soft seeking - 04-08-2006 , 09:45 AM



Hi All,

This is just for a sharing knowledge, I did it by running
below SQL statement:

SELECT *, LOCATE('817145779', ACODE) AS ACODE_PTR FROM ACODE
WHERE ACODE_PTR = 1 ORDER BY ACODE DESC

this will return 8171 .. as I hope

any way .. thanks a lot for any advises.

Regards
Winanjaya

Quote:
I did something kinda similar once - converting from
Foxpro to a relational database and users wanted to list
of stuff above and below what the entered. Not because it
was useful, but because that is the way it worked
before.....

Anyway, you could do the following in a procedure:

Do a like and append a '%' to the parm.
If you get zero rows, remove one character from the end
and try again. Keep going in a loop until you get at least
one row that matches the like.


Without using a procedure, you may also be able to do a
like to get the max record that matches the parm
assuming Acode is your column name this may work:

select max(Acode)
where Acode||'%' like arm (may need to be switched
around to arm like Acode||'%' ).

I haven't tried this specifically so I'm not sure if it
works.



winanjaya> wrote in message
news:4435357c.71ea.1681692777 (AT) sybase (DOT) com... >> In article
4434e753.1a82.1681692777 (AT) sybase (DOT) com>, >> > Winanjaya
says... Dear All,
I had this records below:

ACode
80
81
817
8171
82

The parameter variable value is '817145779' what is
the >> > SQL statement for getting '8171'

We need a lot more information to help you, especially
what is the criteria which decide that 8171 is the
proper >> result?

yes, 8171 is the proper result, because I am soft
seeking '817145779' and '8171' has the most accurate
pattern .. as you see in this record list below:

ACode
80
81
817
8171 ---> this is the most accurate pattern for
817145779
82

hopefully you understand what I need ..

Thanks a lot in advance

Regards
Winanjaya



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.