Anonymní profil peter – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil peter – Programujte.comAnonymní profil peter – Programujte.com

 

Příspěvky odeslané z IP adresy 2001:718:2601:26c:4595:d8...–

peter
MySQL › select zaznamu s historii
25. 11. 2016   #213764

Ta [2.] vypada konkretne nejak takhle
 

CREATE TABLE IF NOT EXISTS `nz_forms` (
  `id_form` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_root` int(10) unsigned DEFAULT NULL,
  `status` int(10) unsigned DEFAULT NULL,
  `name0` varchar(40) DEFAULT NULL,
  `name1` varchar(40) DEFAULT NULL,
  `name2` varchar(40) DEFAULT NULL,
  `name3` varchar(40) DEFAULT NULL,
  `time` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id_form`),
  KEY `id_group` (`status`),
  KEY `id_root` (`id_root`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;

--
-- Dumping data for table `nz_forms`
--

INSERT INTO `nz_forms` (`id_form`, `id_root`, `status`, `name0`, `name1`, `name2`, `name3`, `time`) VALUES
(1, 1, 1, 'aaa 0xyyy', 'bbb 0xx', 'ccc 0xs', 'ddd 0xa', '2016-11-25 09:20:59'),
(3, 1, 0, 'ddd', 'ddd', 'ddd', 'ddd', '2016-11-25 12:26:54'),
(4, 1, 1, 'ddd', 'ddd', 'ddd', 'ddd 0xa', '2016-11-25 09:29:59'),
(5, NULL, 2, 'fsd', 'fds', 'xxxxxxa', 'xxxxxxa', '2016-11-25 09:21:59');

			$pref = '`b`.';
			$query_inner = "
  SELECT 
    IF(c.`id_root` IS NOT NULL, c.`id_root`,c.`id_form`) AS `id_root`,
    Max(c.`time`) AS `time` 
  FROM `$tbl` c
  GROUP BY c.`id_root`
";
			$query1  = "SELECT COUNT(*) AS 'count' FROM ($query_inner) AS ".$pref.$where2;
//			$query2  = "SELECT $query_keys FROM `$tbl`".$where2;
			$query2  = "
SELECT $query_keys 
FROM ($query_inner) AS `a`
  LEFT JOIN `$tbl` `b` ON (`b`.`id_root`=`a`.`id_root` OR `b`.`id_form`=`a`.`id_root`) AND `b`.`time`=`a`.`time` 
".$where2;
			$query2 .= " ORDER BY ".$pref.$SQL->escapeKey($table_order)." LIMIT $table_start, $table_count";
peter
JavaScript, AJAX, jQuery › Jquery list remove
25. 11. 2016   #213758

 Tak, a to je naposledy, co resim neco za tebe zadarmo. Povazuji te za zlodeje.

<script>
a = {a:123, b:456, c:789}
b = [];
function filter(a,b)
{
var i,j,c,bool;
c = {};
for (i in a)
   {
  bool = false; for (j=0; j<b.length; j++) {bool |= b[j] == i}
  if (bool==false) {c[i] = a[i];}
  }
return c;
}
function myclick(val)
{
var c;
b[b.length] = val;
c = filter(a,b)
alert(c.toSource());
}
alert(a.toSource());
myclick('b');
myclick('b');
myclick('c');
myclick('b');

</script>

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý