mysql - How to get random rows including one specific id row -


i have query, select * different tables != $this->player_id -> works fine.

and looks following:

$sql = "     select pi . * , p . *     player_img pi, player p     pi.player_img_category_id = $this->category_id     , pi.player_img_player_id = p.player_id     , pi.player_img_player_id != $this->player_id"; 

what want bit different:

  • select random results , order limit 10
  • inbetween random results one specific row needs there - row should based on $this->player_id

to random results, guess can like:

order rand() limit 10

-however how make sure specific row included:

pi.player_img_player_id == $this->player_id - have no idea on. suggestions?

edit: allinone's answer im looking do- bonus question im wondering if possible sort query results asc p.player_firstname example??

how using union 2 queries different conditions

select q.* (     select pi . * , p . *     player_img pi, player p     pi.player_img_category_id = $this->category_id     , pi.player_img_player_id = p.player_id     , pi.player_img_player_id != $this->player_id     union     select pi . * , p . *     player_img pi, player p     pi.player_img_category_id = $this->category_id     , pi.player_img_player_id = p.player_id     , pi.player_img_player_id = $this->player_id  ) q order rand() limit 10 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -