[b]data in myTable[/b]
[COLOR="Blue"]id name country city sex[/COLOR]
1 john [COLOR="Red"]America[/COLOR] Denver [COLOR="Green"]male[/COLOR]
[B]2[/B] Mary England London female
[B]3[/B] Judy France Chicago female
4 Tom German Berlin [COLOR="green"]male[/COLOR]
5 Carol [COLOR="red"]America[/COLOR] [COLOR="Blue"]Paris[/COLOR] female
6 Jane [COLOR="red"]America[/COLOR] Tokyo female
I have data in myTable like the above.
when I have America(weight 80%), Paris(weight(50%), and male(weight 20%) as 3 keywords,
I like to output like the below.
[b]target result[/b]
(1) Carol // 80%+50%=150%(total weight)
(2) John // 80%+20%=120%
(3) Jane // 80%
(4) Tom // 20%
(5) Mary // 0%
(6) Judy // 0% Judy comes later than Mary because of "ORDER BY [B]ID[/B]"
The following code doesn’t work correctly, but I hope it shows what I want.
[b]would-be code[/b]
select name from myTable
where
weight(country,80%)='America'
or
weight(city,50%)='Paris'
or
weight(sex,20%)='male'
order by ID