order by frequency in multiple columns

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
cardi777
Forum Commoner
Posts: 54
Joined: Sun Mar 29, 2009 4:26 am

order by frequency in multiple columns

Post by cardi777 »

I have a table with 5 columns:
  • tag 1
    tag 2
    tag 3
    tag 4
    tag 5
If I want to show results ordered by the popularity(frequency) of those tags, what kind of query would i use?

Cheers,
Doug
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: order by frequency in multiple columns

Post by josh »

Suggestion: Normalize the table to make the query less difficult.
cardi777
Forum Commoner
Posts: 54
Joined: Sun Mar 29, 2009 4:26 am

Re: order by frequency in multiple columns

Post by cardi777 »

josh wrote:Suggestion: Normalize the table to make the query less difficult.
When you say normalize, do you mean that i combine the keywords into 1 column? Unfortunately its not really an option
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: order by frequency in multiple columns

Post by califdon »

Lookup "normalize" in a relational database textbook or online.
cardi777
Forum Commoner
Posts: 54
Joined: Sun Mar 29, 2009 4:26 am

Re: order by frequency in multiple columns

Post by cardi777 »

okay cool ill check that out
Post Reply