How to record impressions in search results

  • If you have a web site and database that allows people to search.. What is the general strategy if you would like to record how many times a record appears in search results? I could-execute the search (SELECT) query as an UPDATE query to update a "counter" field, but then I'd always be executing two queries every time a search is performed. Seems like a headache.

  • Could not see SQL Server element in the question

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • It is SQL 2008.

  • U can use another table to store searched record... Before insert.... check whether it is there in the new table... if exists... update its counter... else insert it...

    or else u can use group by....

  • tx for the info, but i didn't understand what you are saying..

  • Try aggregating the result set

    Select field1, field2, count(field)

    from

    table

    where some condition = whatever

    group by field1, field2

    We are the pilgrims, master.
    We shall go always, a little further.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply