从 mysql 数据库中的每个值获取最后结果


Get last result from each value in mysql database

我有一个数组,里面有一个马匹列表。

我希望能够通过该阵列并拉动每匹马最后的结果。

目前我的代码如下所示:

select count(*),Horse,Place from horsesrp where Horse In (".$horsearray.")")

我将如何修改它,以便仅显示数组中的马匹最后结果。

下面是我的数组上的输出

Array ( [0] => Sky Watch [1] => Sunny Ledgend [2] => Jupiter Rex [3] => Storm Alert [4] => Alanjou [5] => Strike Fast [6] => Mister Grez [7] => Stone Light [8] => Free World [9] => Humbel Ben [10] => Honour A Promise [11] => Sassanova [12] => Binowagh Bay [13] => Lady Garvagh [14] => Ovilia [15] => Agent Fedora [16] => Dazzling Rita [17] => Moving Waves [18] => Pandy Wells [19] => Frank N Fair [20] => Ruby Valentine [21] => Pennies And Pounds [22] => Never Never [23] => Bertie Moon [24] => Definite Future [25] => If It Be Your Will [26] => Kapstadt [27] => Kayf Blanco [28] => Neworld [29] => Polvere D'oro [30] => Restraint of Trade [31] => Broome Lane [32] => Fine Lily [33] => Pembridge [34] => Capard King [35] => Central School [36] => Coologue [37] => Ma du Fou [38] => Quintano [39] => The Mobb [40] => The Western Force [41] => Youngdocgallagher [42] => Tara Mac [43] => No Principles [44] => Raid Stane [45] => Elton Fox [46] => Minella Bliss [47] => Midnight Dove [48] => Saga de Tercey [49] => Iktiview [50] => Nordic Nymph [51] => Do Be Dashing [52] => Tantalized [53] => Apache Chief [54] => Black Jack Rover [55] => Charlie Cook [56] => Freddie Bear [57] => Rambo [58] => The Late Shift [59] => Tropical Sunshine [60] => Western Xpress [61] => Vitarra [62] => Azure Amour [63] => My Mistress [64] => Royal Roslea [65] => Beach Plaza [66] => Dat Il Do [67] => Surelookit [68] => Bollywood Dream [69] => Dutch Fredie G [70] => Suffolk Sky [71] => Trikasana [72] => Lettuce Snow [73] => Tommy's Secret [74] => Freddy With A Y [75] => Starlight Symphony [76] => Embankment [77] => Gracious George [78] => Presumido [79] => Until Midnight [80] => Gannicus [81] => Next Stop [82] => Woodbridge [83] => Elusive Ellen [84] => Evident [85] => Bobby Benton [86] => Kuwait Star [87] => Ruban [88] => Senator Matt [89] => Strictly The One [90] => Belahodood [91] => Filosofo [92] => Made With Love [93] => Silver Secret [94] => Ladyhawk [95] => Tiger Stone [96] => Thane of Cawdor [97] => Maison Brillet [98] => Idol Deputy [99] => Takeitfromalady [100] => Mcbirney [101] => Bennelong [102] => Eurato [103] => Day Of The Eagle [104] => Fair Comment [105] => Gracefilly [106] => Softly She Treads [107] => Munsarim [108] => Bowsers Bold [109] => Eastward Ho [110] => Burning Blaze [111] => Trader Jack [112] => Brigliadoro [113] => Midnight Rider [114] => Good Luck Charm [115] => Ertikaan [116] => Palace Moon [117] => Don't Be [118] => Toga Tiger [119] => Footstepsintherain [120] => Polar Kite [121] => Conry [122] => Sheikh The Reins [123] => Whaleweigh Station [124] => Light From Mars [125] => Strategic Force [126] => Lady Brigid [127] => Secret Asset [128] => Nonno Giulio [129] => Head Space [130] => Time And Place [131] => Secret Millionaire [132] => Drive On [133] => Clockmaker [134] => Angus Glens [135] => Dont Take Me Alive [136] => Greeleys Love [137] => Arashi [138] => Addazero [139] => Montaff [140] => Guards Chapel [141] => Leyland [142] => Artisan [143] => Golden Bird [144] => Sparkling Ice [145] => Rookery [146] => Haines [147] => Ballyfarsoon [148] => Bahango [149] => Kyrenia Castle [150] => Bahama Blue [151] => Desert Apostle [152] => Vivre La Reve [153] => Thataboy [154] => Royal Acquisition [155] => Pensax Lad [156] => Captain Whoosh [157] => Scoreline [158] => West Coast Dream [159] => Profile Star [160] => Pearl Noir [161] => Bilash [162] => Black Dave [163] => Argent Touch [164] => Mr Mo Jo [165] => Island Express [166] => Sir Billy Wright [167] => Summersault [168] => Windy Miller [169] => Zat Be Zat [170] => Nelson's Pride [171] => Princess Rose [172] => Zaria [173] => Shyron [174] => Monsea [175] => Silverware [176] => Corporal Maddox [177] => Mr Bossy Boots [178] => Loyalty [179] => Smokethatthunders [180] => Order Of Service [181] => Ace Master [182] => Rasaman [183] => Beedee [184] => Rich Again [185] => Ruggero [186] => Tukitinyasok [187] => Keeper's Ring [188] => Catching Zeds [189] => Pipers Piping [190] => Tsarglas [191] => Key To Your Heart [192] => Katmai River [193] => Spokesperson [194] => Navajo Dream [195] => Courtezan [196] => Ambella [197] => Russian Ice [198] => Boboli Gardens [199] => Sarlat [200] => Look Here's Al [201] => Postillion [202] => Cherry Tiger [203] => Celestial Dawn [204] => Previous Acclaim [205] => Dutch Lady Roseane [206] => L'inganno Felice [207] => Take Two [208] => A Little Bit Dusty [209] => Amazing Star [210] => Aneedh [211] => Dialogue [212] => Gabrial The Duke [213] => Swift Cedar [214] => Menelik [215] => Gilmer [216] => Sheriff Of Nawton [217] => Dansili Dutch [218] => Disclosure [219] => Royal Trooper [220] => Helmsley Flyer [221] => Taroum [222] => Reality Show [223] => Pim Street [224] => Cropley [225] => Dhaular Dhar [226] => Qibtee [227] => Uganda Glory [228] => Master Of Song [229] => Cabuchon [230] => Percys Princess ) 

数据库保存赛马的结果,所以我想得到每匹马的最后结果

运行以下 SQL 命令将生成以下内容:"选择地点,马从马在马中的位置(".$horsearray.")"

海恩斯再次富有乌干达荣耀再次富有萨尔拉富奇再次亲切 乔治夫人布里吉德里奇再次烟雾雷霆对话L'Inganno 菲利斯黑珍珠

如所见,Rich 再次显示几次,我只想得到最后一个结果(仅 1 个结果)

我已经尝试过"select Place, Horse from horsesrp where Horse In (".$horsearray.") limit 1"但这只是返回第一匹马海恩斯

我想我明白你想做什么......

选择(选择"从马啪"中放置作为 rp 其中 rp。马 = 马顺序 按id DESC 限制 1) 作为place,马从马斯普马在(".$horsearray.")")

我希望id是您的主键,它是一个整数。也应该适用于日期时间或日期列。