Update Row = Row - 1将行设置为0

时间:2015-06-05 13:58:59

标签: php

我试图将1或1添加到行中,如下所示:

public static void Main()
{
    string one = @"C:\aaaa\bbbb\cccc";
    string two = @"cccc\dddd";

    int overlapIndex = one.IndexOf(two.Split('\\').First());

    string three = one.Substring(0, overlapIndex) + two;

    Console.WriteLine(three);
    // "C:\aaaa\bbbb\cccc\dddd"
}

但数量和购买在每个查询中都为0。我不知道为什么

1 个答案:

答案 0 :(得分:0)

您错过了正确的mysql UPDATE语法,因为当您想要更新多个列时,,而不是AND。点击此处https://dev.mysql.com/doc/refman/5.0/en/update.html

UPDATE t1 SET col1 = col1 + 1, col2 = col2 - 1;
                            ^^^ 

对于您的查询,

$updatequality = $database->prepare("UPDATE products SET quantity=quantity - 1 , purchases=purchases + 1 WHERE id=?");