Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    select LEFT sql database

    I need the select statement that will select the first 3 characters of the field.

    For instance:

    Field1 = 123,345
    Field2 = 123,980
    Field3 = 234,487
    Field4 = 456,1234
    Field5 = 1234,7863

    I want to select the first (LEFT) 3 characters that are equal to "123"...So technically Field1, Field2, Field5 would be retreived.

    I am an avid programmer in PHP, learning ASP (server doesn't support .NET)...anyways this is what the select statement would look like in PHP:

    PHP Code:
    SELECT idnameLEFT(comments25FROM comments ORDER BY cdate DESC LIMIT 5
    Thanks for the help in advance

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    All you're missing is the where clause:
    PHP Code:
    select left(field3from tbl where left(field3) = 123 
    Good luck;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •