Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #15563

Re: sql with 3 tables

From alex <alex@nomailno.it>
Newsgroups comp.lang.php
Subject Re: sql with 3 tables
Date 2015-07-05 12:36 +0200
Organization Aioe.org NNTP Server
Message-ID <mnb1b1$9qb$1@speranza.aioe.org> (permalink)
References <mnauin$3lj$1@speranza.aioe.org> <5s7mx.1583$sG4.1199@fx25.fr7>

Show all headers | View raw


 > UPDATE
 >      a
 > SET
 >      a.totale = a.aa + c.bb
 > FROM
 >      a AS a,
 >      b AS b,
 >      c AS c
 > WHERE
 >      a.id = c.id
 >      AND c.id = b.id
 >      AND b.x < c.y
 >


I must to have this (semplified code)
UPDATE  A AS A
INNER JOIN C AS C
ON      A.id = C.id
SET     A.tot = 1
WHERE (B.x < C.y  WHERE B.id=C.id) <--- to solve

from 3 tables,
on  A to change the column tot depending comparision between B and C

A           C                  B
id tot      id  maxacquist     id acquist
10 0        8      10           8   3
9  0        6     null          6   5
8  0        5      6            5   6
7  0        4      1            4   2
6  0
5  0
4  0
3  0
2  0
1  0


after comaprision B and C
id  C  >  B        insert this value in A
8  10     3              0
6  null   5              0
5  6      6              1
4  1      2              1


notice that in column A there are records that there aren't in B and C

think your suggest is ok












Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

sql with 3 tables alex <alex@nomailno.it> - 2015-07-05 11:49 +0200
  Re: sql with 3 tables adam <adam@nospam.net> - 2015-07-05 10:14 +0000
    Re: sql with 3 tables alex <alex@nomailno.it> - 2015-07-05 12:36 +0200
      Re: sql with 3 tables Luuk <luuk@invalid.lan> - 2015-07-05 19:06 +0200
    Re: sql with 3 tables alex <alex@nomailno.it> - 2015-07-05 16:41 +0200
      Re: sql with 3 tables Jerry Stuckle <jstucklex@attglobal.net> - 2015-07-05 11:18 -0400
      Re: sql with 3 tables adam <adam@nospam.net> - 2015-07-05 17:14 +0000
      Re: sql with 3 tables adam <adam@nospam.net> - 2015-07-05 17:28 +0000
        Re: sql with 3 tables alex <alex@nomailno.it> - 2015-07-14 11:07 +0200
      Re: sql with 3 tables Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-06 03:28 +0200
    Re: sql with 3 tables alex <alex@nomailno.it> - 2015-07-05 18:07 +0200

csiph-web