我卡住了我想用codeigniter函数执行sql查询,但我不能
SELECT Players.Pseudo as Pseudo,
COUNT(CASE WHEN Games.Gagnant = Players.IdPlayer THEN 1 END) AS Victoires,
COUNT(CASE WHEN Games.Gagnant != Players.IdPlayer THEN 1 END) AS Defaites
,
ROUND(COUNT(CASE WHEN Games.Gagnant = Players.IdPlayer THEN 1 END)/COUNT(CASE WHEN Games.Gagnant != Players.IdPlayer THEN 1 END),2) AS Ratio
FROM Players
LEFT JOIN Games ON Players.IdPlayer = Games.IdJoueur1 OR Players.IdPlayer = Games.IdJoueur2;
我试过了,但是没用...
$builder=$this->db->table('Players');
$recherche = $_POST['recherche'];
$where = "Players.Pseudo = $recherche AND Players.IdPlayer = Games.IdJoueur1 OR Players.IdPlayer = Games.IdJoueur2";
$join = $builder->join('Games', $where);
$table = $join->get();
$query = $table->select('Players.Pseudo as Pseudo, COUNT(CASE WHEN Games.Gagnant = Players.IdPlayer THEN 1 END) AS Victoires, COUNT(CASE WHEN Games.Gagnant != Players.IdPlayer THEN 1 END) AS Defaites
, ROUND(COUNT(CASE WHEN Games.Gagnant = Players.IdPlayer THEN 1 END)/COUNT(CASE WHEN Games.Gagnant != Players.IdPlayer THEN 1 END),2) AS Ratio');
$classement = $query->get()->getResultArray();
1条答案
按热度按时间btxsgosb1#
谢谢你的回复!你会看到更多的风格要求?但这也不起作用...