none
Query Commands

    Question

  • Ok. I am trying to use the query command "LIKE", but its not working. I have a row with the name Ben Stuart - A moment inside. When I use the following code:

    SELECT * FROM TableName WHERE Title LIKE '?e*';

    and its not working, it just shows a blank table. But when I use the following code:

    SELECT * FROM TableName WHERE Title LIKE 'B%'

    ..then it works just fine. I know the first block of code is to match the criteria to the second letter, and the second block of code is to match the search criteria to the first letter. I just cant seem to get the one where it searchs for the second letter. Can someone help?
    Wednesday, December 14, 2005 8:06 AM

Answers

  • SQL does not work on Regular Expressions.
    It will work on special wildcard characters only (they being %, _ [underscore], square brackets [], and [ ^ ] to signify the characters not to include).

    You could use underscore because this works on the same format as * ... rather than ? actually.
    You can make it:-  LIKE '_c%'
    This will look for any word that starts off with any character but has c as the second character and does not care about any occurrence of the characters thereafter.

    I hope that solves the problem.

    Wednesday, December 14, 2005 8:32 AM

All replies

  • SQL does not work on Regular Expressions.
    It will work on special wildcard characters only (they being %, _ [underscore], square brackets [], and [ ^ ] to signify the characters not to include).

    You could use underscore because this works on the same format as * ... rather than ? actually.
    You can make it:-  LIKE '_c%'
    This will look for any word that starts off with any character but has c as the second character and does not care about any occurrence of the characters thereafter.

    I hope that solves the problem.

    Wednesday, December 14, 2005 8:32 AM
  • Thank you for that clarification. Could you also tell me how, when I perform a query, for the row width to be increased. The width always seems too short.
    Wednesday, December 14, 2005 5:08 PM
  • Didn't quite get your question over there. Do you mean you want to change the width of the column from a web application or the SQL database itself. In my case, I tried from SQL, it works just fine, changes the width according to the data output. If you are talking about web applications then change the column setting to be "auto".
    Thursday, December 15, 2005 12:47 AM