我一直在試圖完成過去幾個小時以下沒有任何的運氣:選擇其中列1 = COLUMN2
$stmt = $db->query("SELECT league_match_id as match_id, league_match_home_team as home_team, league_match_away_team as away_team FROM $table WHERE ((home_team = away_team) AND (away_team = home_team))");
比方說,我們有TEAM1和TEAM2。在Team1在家並且Team2不在的情況下進行比賽。另一場比賽(排)存儲在team2在家且team1不在的地方。我想用一個查詢來選擇兩個團隊。
還沒有球隊在打自己,我試圖讓2行,其中HOME_TEAM和AWAY_TEAM的值被鏡像。
任何人都可以幫助我走上正軌嗎?
* UPDATE *
我得到回報如下:
Array
(
[0] => Array
(
[t1_id] => 26
[t1_home] => 2
[t1_away] => 1
[t2_id] => 24
[t2_home] => 1
[t2_away] => 2
)
[1] => Array
(
[t1_id] => 28
[t1_home] => 3
[t1_away] => 1
[t2_id] => 25
[t2_home] => 1
[t2_away] => 3
)
[2] => Array
(
[t1_id] => 24
[t1_home] => 1
[t1_away] => 2
[t2_id] => 26
[t2_home] => 2
[t2_away] => 1
)
[3] => Array
(
[t1_id] => 29
[t1_home] => 3
[t1_away] => 2
[t2_id] => 27
[t2_home] => 2
[t2_away] => 3
)
[4] => Array
(
[t1_id] => 25
[t1_home] => 1
[t1_away] => 3
[t2_id] => 28
[t2_home] => 3
[t2_away] => 1
)
[5] => Array
(
[t1_id] => 27
[t1_home] => 2
[t1_away] => 3
[t2_id] => 29
[t2_home] => 3
[t2_away] => 2
)
)
如果雙方陣[0]和陣列[2]是一樣的,他們只是鏡像。我可以擺脫這裏的重複嗎?我很想擁有Array [0]或Array [2]。這可能嗎?
表中數據的一個小例子,以及你想從數據中返回的結果集可以很好地解釋你想要的東西。 – spencer7593