【发布时间】:2014-03-06 20:44:42
【问题描述】:
我正在寻找一种方法来从数据库中选择前三名的用户,然后是前五名,包括前三名,不包括之前选择的前三名。代码如下:
$strSQL = "SELECT id FROM ".USERS_TABLE." ut, ".USER_MATCH_TABLE." umt WHERE ".implode(' AND ', $where). " AND ut.id=umt.id_user AND (ut.a='$a1' OR ut.b='$b1' OR ut.c='$c1' OR ut.d='$d1' OR ut.e='$e1' OR ut.f='$f1' OR ut.g='$g1' OR ut.h='$h1' OR ut.i= '$i1' OR ut.j='$j1' OR ut.k='$k1' OR ut.l='$l1' OR ut.m='$m1' OR ut.n='$n1' OR ut.o='$o1' OR ut.p='$p1' OR ut.q='$q1' OR ut.r='$r1' OR ut.s='$s1' OR ut.t=' $t1' OR ut.u='$u1' OR ut.v='$v1' OR ut.w='$w1' OR ut.x='$x1' OR ut.y='$y1' OR ut .z='$z1' OR ut.aa='$aa1' OR ut.ab='$ab1' OR ut.ac='$ac1' OR ut.ad='$ad1' OR ut.ae='$ ae1' OR ut.af='$af1' OR ut.ag='$ag1' OR ut.ah='$ah1') AND (ut.a='$a2' OR ut.b='$b2' OR ut.c='$c2' OR ut.d='$d2' OR ut.e='$e2' OR ut.f='$f2' OR ut.g='$g2' OR ut.h=' $h2' OR ut.i='$i2' OR ut.j='$j2' OR ut.k='$k2' OR ut.l='$l2' OR ut.m='$m2' OR ut .n='$n2' OR ut.o='$o2' OR ut.p='$p2' OR ut.q='$q2' OR ut.r='$r2' OR ut.s='$ s2' OR ut.t='$t2' OR ut.u='$u2' OR ut.v='$v2' OR ut.w='$w2' OR ut.x='$x2' OR ut. y='$y2' OR ut.z='$z2' OR ut.aa='$aa2' OR ut.ab='$ab2' OR ut.ac='$ac2' OR ut.ad='$ad2 ' OR ut.ae='$ae2' O R ut.af='$af2' OR ut.ag='$ag2' OR ut.ah='$ah2' 或 ut.a='$a1' OR ut.b='$b1' OR ut.c= '$c1' OR ut.d='$d1' OR ut.e='$e1' OR ut.f='$f1' OR ut.g='$g1' OR ut.h='$h1' OR ut.i='$i1' OR ut.j='$j1' OR ut.k='$k1' OR ut.l='$l1' OR ut.m='$m1' OR ut.n=' $n1' OR ut.o='$o1' OR ut.p='$p1' OR ut.q='$q1' OR ut.r='$r1' OR ut.s='$s1' OR ut .t='$t1' OR ut.u='$u1' OR ut.v='$v1' OR ut.w='$w1' OR ut.x='$x1' OR ut.y='$ y1' OR ut.z='$z1' OR ut.aa='$aa1' OR ut.ab='$ab1' OR ut.ac='$ac1' OR ut.ad='$ad1' OR ut. ae='$ae1' OR ut.af='$af1' OR ut.ag='$ag1' OR ut.ah='$ah1')"; $rs = $dbconn->执行($strSQL);
while ($array = $rs->FetchRow()) {
$ids[] = $array[0];
}
查询的第一组是 AND(ut.a='$a1'or 等),第二部分在 and 之后,包括前三、四和五的第一部分。我想从前五名中排除前三名中包含的任何内容。有任何想法吗?我想到了一个数组,但复杂性超出了我的范围。提前致谢
【问题讨论】: