Expression > Forums Home > Expression Studio Forums > Expression Web and SuperPreview > Structure a 'Where' Statement in Gridview
Ask a questionAsk a question
 

AnswerStructure a 'Where' Statement in Gridview

  • Friday, November 06, 2009 6:24 PMjaymike Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    How do I structure the 'Where' statement so that the results will return the records where the first letter of the column field begins with a letter entered in the search box by the user?
    I'm able to to use the 'like' option where the results return all records containing the entered letter, but I need only the first letter.
    Also, is there a default option like a (%) which when entered in the search box will return all records?

Answers

  • Friday, November 06, 2009 8:59 PMjaymike Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    ClarkNK,
    Worked like a charm. Thank you very much.
    btw, your tutorials have been a great help to me as I transition from FP to EW.
    Thanks again.
    • Marked As Answer byjaymike Friday, November 06, 2009 8:59 PM
    •  

All Replies

  • Friday, November 06, 2009 7:09 PMVeignMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What is the database?  In MySQL you would use the LEFT string function .
    --
    Chris Hanscom - Microsoft MVP
    On Facebook | On Twitter | Resource Center | Veign's Blog | Web Development Help

    Get a Complete Website Analysis by Veign
  • Friday, November 06, 2009 8:22 PMjaymike Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It's a MS Access database
  • Friday, November 06, 2009 8:27 PMVeignMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    This states:
    http://www.databasedev.co.uk/access-sql-string-functions.html

    That Access supports the LEFT function.

    So try (air-code) something like to return records where myfield starts with A:
    SELECT myfield FROM mytable WHERE LEFT(myfield, 1) = 'A'
    --
    Chris Hanscom - Microsoft MVP
    On Facebook | On Twitter | Resource Center | Veign's Blog | Web Development Help

    Get a Complete Website Analysis by Veign
  • Friday, November 06, 2009 8:36 PMClarkNK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    If your current statement is like this:

    WHERE ([field] LIKE '%' + ? + '%')

    then change it to like this:

    WHERE ([field] LIKE ? + '%')
    ClarkNK, A.K.A. HomePage Doctor
    HomePageDoctor.com -- Expression Web database tutorials
    Ownertrades.com -- Created with FP, Access, Bots and Wizards
    MyNumbersTracker.com -- Created with Expression, VWDExress, SQL Express, and ASP.NET.
    • Proposed As Answer bypaladyn Saturday, November 07, 2009 2:55 AM
    •  
  • Friday, November 06, 2009 8:59 PMjaymike Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    ClarkNK,
    Worked like a charm. Thank you very much.
    btw, your tutorials have been a great help to me as I transition from FP to EW.
    Thanks again.
    • Marked As Answer byjaymike Friday, November 06, 2009 8:59 PM
    •  
  • Friday, November 06, 2009 9:28 PMpaladyn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    ClarkNK,
    Worked like a charm. Thank you very much.
    btw, your tutorials have been a great help to me as I transition from FP to EW.
    Thanks again.
    Jaymike, just so you know, it is appropriate to Mark As Answer the post that actually answered your question, not your own reply. In this case, that would be Clark's post, above.

    The reason is that not only is it polite to recognize the contribution of whomever solved your problem, but it also helps others to find the answer when searching the forum. You will note that the post marked as answer is highlighted in green and copied to the top of the thread. This makes it easy for others to find the post which provided the actual answer. As you can probably see, your reply doesn't do much to answer the topic question. ;-)

    You're new to the forum, so this probably hasn't been pointed out to you before. Just thought you'd like to know...

    cheers,
    scott

    Plural's don't have apostrophe's. It seem's sometime's that any word's ending in "s" get a gratuitous apostrophe. Apostrophe's are used to indicate possessive's and elision's (contraction's or abbreviation's).
  • Friday, November 06, 2009 9:50 PMjaymike Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks for the advice. Pls excuse my ignorance.