+ Reply to Thread
Results 1 to 2 of 2

Thread: How to query all letter entries?

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    15

    How to query all letter entries?

    I am trying to query by letter as follows:
    Code:
    Group.where("title like ?", "#{@letter}%")
    This works great for a-z... What can I pass to @letter, to get all digit entries. Entries that start with 1, or 500 or some other non a-z character for example?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    41
    You can use Regular Expression to get a match for what you need , like below :
    Code:
    SELECT *
    FROM   tbl
    WHERE  title ~ E'^\\w.*';
    What this regular expression actually does is getting all strings that begins with a non a-z characters.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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