Posted by Alex Kuznetsov on 01/22/07 18:36
SQL Learner wrote:
> Thanks again, Alex.
>
> I am having problem put the SQL in Access. Could you tell me the logic
> of the select statement?
>
> (SELECT MIN(Value) FROM TblWord_Number WHERE Street LIKE '%'+Word+'%'
> AND Street LIKE CAST(Number AS VARCHAR(50))+'%')
>
> Why are we using Min(Value) and what does "CAST(Number AS
> VARCHAR(50))+'%')" mean and do?
>
> I got your partial matching SQL code as follow:
>
> ========================
> SELECT t.*
> FROM tblStreet AS t
> WHERE (((Exists (SELECT 1 FROM tblWord w WHERE t.Street LIKE
> '*'+Word+'*'))<>False));
> ========================
>
> I seems a little different from your new one.
>
> This seems like a difficult query. Please help.
>
> - Grasshopper -
If Number column is numeric, I cannot concatenate '%' to it directly, I
need to convert is to character type first.
Because the subquery without MIN() can return more than one value and
blow up, I need to restrict it to one value. i could use TOP 1 instead
of MIN(). You might get better help an an Access newsgroup.
-----------------------
Alex Kuznetsov
http://sqlserver-tips.blogspot.com/
http://sqlserver-puzzles.blogspot.com/
[Back to original message]
|