Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2009
    Posts
    5

    Question Unanswered: Update Query Problem.

    Hi,

    I have use MS SQL with PHP.

    and I write the code in php for update some rows in our transaction table. but not update all selected rows.
    for examp. i have select 9000 rows in a table. and i run the update query with while loop. but not update more than 3000 rows. when i update all 9000 rows.
    and automatically stop the update program.


    Firoj

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Dude - do you think mebbe the code would be useful for us?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Mar 2009
    Posts
    5
    while($j > 1)
    {

    $sn1= mssql_result($rs,$j,"txsn");
    $refno3= mssql_result($rs,$j,"txrefno3");


    $sql1="update sb_transaction
    set tx_cp = '$refno3'
    where txsn = $sn1";

    mssql_query($sql1);
    echo $j;
    ?>
    <br>
    <?
    $j=$j-1;

    }

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    My bet is that the values you derive for $sn1 do not account for every value of txsn in sb_transaction. Can txsn be NULL?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Mar 2009
    Posts
    5
    no txsn is not null it have value. but txrefno3 have some null value.

  6. #6
    Join Date
    Mar 2009
    Posts
    5
    and the upper query is this where i fetch data in table.

    $sql = "select * from sb_transaction
    where txqtyin1!='' or txqtyin2!='' and txqtyout1='' and txqtyout2=''";

    $rs = mssql_query($sql);
    $num_rows = mssql_num_rows($rs);
    $j =$num_rows;

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by firojshekh
    $sql = "select * from sb_transaction
    where txqtyin1!='' or txqtyin2!='' and txqtyout1='' and txqtyout2=''";
    That looks wrong.
    Do you mean this?
    Code:
    $sql = "select * from sb_transaction 
            where (txqtyin1!='' or txqtyin2!='') and txqtyout1='' and txqtyout2=''";
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    Mar 2009
    Posts
    5
    No dear, the query is proper working but when i run the php programm then not complete rows is update. only 3400 something rows is update. and i have result for this query is 9140 rows.

  9. #9
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Please can you execute the below in SQL Server Management Studio (or Query Analyser if you are using SQL Server 2000) and confirm for me that for the below data the first query returns the correct result and the second query returns an incorrect result:
    Code:
    DECLARE    @t TABLE
        (
              txqtyin1        VARCHAR(1)    NULL
            , txqtyin2        VARCHAR(1)    NULL
            , txqtyout1        VARCHAR(1)    NULL
            , txqtyout2        VARCHAR(1)    NULL
        )    
    
    INSERT INTO @t
    SELECT    'a', '', 'a', ''
    
    SELECT    * 
    FROM    @t
    WHERE    txqtyin1!='' or txqtyin2!='' and txqtyout1='' and txqtyout2=''
    
    SELECT    * 
    FROM    @t
    WHERE    (txqtyin1!='' or txqtyin2!='') and txqtyout1='' and txqtyout2=''
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •