Returning a partial string

jda jda at his.com
Thu Jul 7 16:19:14 CDT 2005


>  >
>>  SELECT * from table ORDER BY Left(textField, (LOCATE(chr(13), textfield)))
>>
>>  looks like it might retrieve the first name, but would get nothing if
>>  there was no return char.
>>
>>  Any ideas?
>
>First of all, I'd suggest put this formula into Table Method,
>Because they you get permanent index on it.

OK, although speed here is not important. Not having to alter 
existing tables is a plus.

>
>Second, I think it needs put formula into SELCT
>And use
>   
>     ORDER 12

ORDER 12? Sorry, I don't understand.

>
>Or give it in select alias name
>
>SELECT Left(textField, (LOCATE(chr(13), textfield))) as 'aaa'
>FROM T
>ORDER BY aaa
>

Um, but I need to recover all fields. And actually I'll be doing 
several sorts at once:

ORDER BY Left(textField, (LOCATE(chr(13), textfield))), textfield2, textfield3

Also, if LOCATE(chr(13)) = 0 (if there is only one name) then the 
sort will be on nothing.

I think this is going to require a lot of thought.

Thanks.

Jon


More information about the Valentina-beta mailing list