SQL有LEFT函数,在DELPHI中,这函数如何写?

解决方案 »

  1.   

    uses StrUtils;function LeftStr(const AText: string; const ACount: Integer): string;
    function RightStr(const AText: string; const ACount: Integer): string;
    function MidStr(const AText: string; const AStart, ACount: Integer): string;function LeftStr(const AText: string; const ACount: Integer): string;
    begin
      Result := Copy(AText, 1, ACount);
    end;function RightStr(const AText: string; const ACount: Integer): string;
    begin
      Result := Copy(AText, Length(AText) + 1 - ACount, ACount);
    end;function MidStr(const AText: string; const AStart, ACount: Integer): string;
    begin
      Result := Copy(AText, AStart, ACount);
    end;
      

  2.   

    在sql server 2000中
    A. 对列使用 LEFT 函数
    下面的示例返回每个书名最左边的 5 个字符。USE pubs
    GO
    SELECT LEFT(title, 5) 
    FROM titles
    ORDER BY title_id
    GO下面是结果集:----- 
    The B 
    Cooki 
    You C 
    Strai 
    Silic 
    The G 
    The P 
    But I 
    Secre 
    Net E 
    Compu 
    Is An 
    Life  
    Prolo 
    Emoti 
    Onion 
    Fifty 
    Sushi (18 row(s) affected)B. 对字符串使用 LEFT 函数
    下面的示例使用 LEFT 函数返回字符串 abcdefg 最左边的 2 个字符。SELECT LEFT('abcdefg',2)
    GO下面是结果集:-- 
    ab (1 row(s) affected)
      

  3.   

    sorry;没看清楚题;^_^;当我没贴;