Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Unanswered: Database searching help

    I have a table with 1000 records (each record contains a field with webpage
    code).

    I need to search records for a $string and sort result by number of
    occurrences of a string in a record (eg. first comes the record with 5
    occurrences of $string, then a record with 4 occurrences, ...).

    How can I do this in SQL?

    Thanks.

  2. #2
    Join Date
    Sep 2002
    Location
    Montreal, Canada
    Posts
    224
    Provided Answers: 1

    Re: Database searching help

    Originally posted by hecky
    I have a table with 1000 records (each record contains a field with webpage
    code).

    I need to search records for a $string and sort result by number of
    occurrences of a string in a record (eg. first comes the record with 5
    occurrences of $string, then a record with 4 occurrences, ...).

    How can I do this in SQL?

    Thanks.
    SELECT count(*) as total, column1, column2, column3, column4
    FROM YourTableName
    WHERE column1 like '%TheStringIAmSearchingFor%'
    GROUP BY total
    order by total desc, column1 asc

Posting Permissions

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