/    Sign up×
Community /Pin to ProfileBookmark

MySQL Order Of Importance

[code=php]$query = “SELECT artist,lyric,title,album,
MATCH(artist) AGAINST (‘$trimmed’ IN BOOLEAN mode) AS score1,
MATCH(album) AGAINST (‘$trimmed’ IN BOOLEAN mode) AS score2,
MATCH(title) AGAINST (‘$trimmed’ IN BOOLEAN mode) AS score3,
MATCH(lyric) AGAINST (‘$trimmed’ IN BOOLEAN mode) AS score4
FROM lyrics
WHERE
MATCH(artist, album, title, lyric) AGAINST (‘$trimmed’ IN BOOLEAN mode) ORDER BY score1,score2,score3,score4″;[/code]

I am trying to get these to order by order of importance… Where artist ranks higher than album which is higher than title, which is above lyric. I just can’t get this to work.

Someone told me to do this when using the above SQL:

[QUOTE]

In the PHP calculate $score as ($score1 * 4) + ($score2 * 3) + ($score3 * 2) + ($score4 * 1)

[/QUOTE]

But I don’t understand what he means by this.

Could someone help me out?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@hyperliskNov 22.2006 — Try

[code=php]
$query = "SELECT (artist,lyric,title,album) FROM lyrics ORDER BY artist,album,title,lyric"[/code]
×

Success!

Help @The_Little_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...