I am trying to get a line with the highest id from a group, instead of the least I have heard that you To do this, move JOIN
, but this is confusing and I can not get my head around it.
My code so far is:
$ userp0l = // userID $ where = // Choose forums id * FROM `noti` WHERE forum = '$ where' and Users & lt; & Gt; This is done by the '$ Userp0l' group by the user order, `id`dec
, although it is showing the first entry in the group instead of the latest group. Anyone know how I can write it?
I just said that I would post all my code, but seeing this, there really is not much. I run this statement:
$ elist = mysql_query ("SELECT * FROM` noti` WHERE forums = '$ where' and users & lt; & gt; '$ userp0l' by user Order 'ID' DESC) or die (MyScale_Arer ());
This information gets information from the database, the information is grouped, when I go to tenant data in the table, I do not catch the user twice:
if (mysql_num_rows ($ elist)> gt0) {while $ $ elist_result = mysql_fetch_array ($ iList)) {$ showotir = $ elist_result [' Show '$'; $ Userr = $ elist_result ['user']; $ forumr = $ elist_result ['platform']; if ($ showotir == "n") {$ pps = "INSERT INTO`` `` `user `(` $ Userr ',' $ where ',' 0 ',' $ forumn ',' $ uu ')'; MySql_query ($ '', `$ ' Pps) or die (mysql_error ());} other {$ pps = "INSERT`` noti` (`user ',` forum`, `showout`,` pramunam`,' made ') value (' $ userr ',' $ Where ',' 1 ',' $ emerged ',' $ uu ') "; Mysql_query ($ pps) or die (mysql_error ()); }
I need to know that the most recent entry of showoti
is a 1
or 0
. The problem is, when grouping takes the latest instead of the latest entry, so if the most recent entry has showoti
value of 0
, but the first entry value in 1
, then it will always show 1
because it is seeing the first entry, basically I want to order groups back.
use
choose 'user', `showtext ' From 'Noti' to the stage = '97' and the user & lt; & Gt; You must remember that 4 (420) is greater than 1 (1350), '9 7 7' group by 'user', `showing` `id` dsc
by order, So your sorting may need to be slightly different I have created one.
Comments
Post a Comment