php - Order mysql query by id but also by extra part -


i trying order db table champion name using id table , if id = champion id order.

i tried not order seems miss place rows in order think query missing something. have tried asc , desc , still comes out buggy

select plat_plus_champion_stats.* plat_plus_champion_stats, champion_data concat(plat_plus_champion_stats.champ_id, '.jpg') =  champion_data.champion_sub_background order champion_data.champion 

the aim data table

champion_data table

id    champion    champion_sub_background         ---|------------|-------------------------| 6  |   janna    |         80.jpg          |      5  |   karthus  |         123.jpg         |       7  |   aatrox   |         45.jpg          |    1  |   talon    |         95.jpg          |            

plat_plus_champion_stats table

id    champ_id            ---|------------| 6  |     80     |      5  |     45     |      7  |    123     |   1  |     95     | 

the aim champ_id , compare champion_sub_background if both same number show champion ordered desc.

i shortened table names clarity. using select, it's difficult see if order correct:

select stats.*  champion_data data, plat_plus_champion_stats stats  concat(stats.champ_id, '.jpg')=data.champion_sub_background  order data.champion desc   id  champ_id 1   95 7   123 6   80 5   45 

so added in table names:

select stats.*, data.*  champion_data data, plat_plus_champion_stats stats  concat(stats.champ_id, '.jpg')=data.champion_sub_background  order data.champion desc   id  champ_id    id  champion   champion_sub_background   1   95          1   talon       95.jpg 7   123         5   karthus     123.jpg 6   80          6   janna       80.jpg 5   45          7   aatrox      45.jpg 

your query working fine; needs desc in order by. got confused id field. doesn't match between 2 tables-- notice difference between id fields karthus , aatrox. it'd easy confused using them judge if order correct.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -