如何在特定列的一个查询中更新多行值

时间:2019-06-20 05:56:59

标签: mysql

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

</head>

<body>

  <nav class="navbar navbar-expand-lg bg-dark navbar-dark sticky-top">
    <a class="navbar-brand" href="#"><img class="img-responsive" src="/testing/users/images/logo.png"></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="collapsibleNavbar">
      <ul class="navbar-nav  ml-auto">
        <li class="nav-item"><a href="/testing/" class="nav-link"><span class="fa fa-fw fa-home"></span> Home</a></li>
        <li class="nav-item"><a href="/testing/users/account.php" class="nav-link"><span
              class="fa fa-fw fa-user"></span> admin</a></li>
        <li class="nav-item">
          <a href="/testing/users/messages.php" class="nav-link">
            <span class="fa fa-envelope"></span><i class="badge"></i> Message</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="dropdown_main" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="fa fa-fw fa-cogs"></span> <span class="caret"></span>Settings</a>
          <div class="dropdown-menu dropdown-info" aria-labelledby="dropdown_main">
            <a class="dropdown-item" href="/testing/"><span class="fa fa-fw fa-home"></span> Home</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="/testing/users/account.php"><span class="fa fa-fw fa-user"></span>
              Account</a>
            <a class="dropdown-item" href="/testing/users/admin.php"><span class="fa fa-fw fa-cogs"></span> Admin
              Dashboard</a>
            <a class="dropdown-item" href="/testing/users/admin.php?view=users"><span class="fa fa-fw fa-user"></span>
              User Management</a>
            <a class="dropdown-item" href="/testing/users/admin.php?view=permissions"><span
                class="fa fa-fw fa-lock"></span> Permissions Management</a>
            <a class="dropdown-item" href="/testing/users/admin.php?view=pages"><span class="fa fa-fw fa-wrench"></span>
              Page Management</a>
            <a class="dropdown-item" href="/testing/users/admin.php?view=messages"><span
                class="fa fa-fw fa-envelope"></span> Messages Manager</a>
            <a class="dropdown-item" href="/testing/users/admin.php?view=logs"><span class="fa fa-fw fa-search"></span>
              System Logs</a>
            <a class="dropdown-item" href="/testing/users/logout.php"><span class="fa fa-fw fa-sign-out"></span>
              Logout</a>
          </div>
        </li>
        <li class="nav-item dropdown menu">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
           <span
                class="fa fa-fw fa-lock"></span> menu
          </a>
          <div class="dropdown-menu w-100" aria-labelledby="navbarDropdown">
            <a class="dropdown-item mx-auto" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Another action</a>
          </div>
        </li>
      </ul>
    </div>
  </nav>
</body>

</html>

1 个答案:

答案 0 :(得分:0)

 UPDATE
   job_seekers
 SET
    js_email = CASE WHEN js_email = 'Wbsirota@gmail.com' THEN 
    'bsirota@gmail.com' WHEN js_email = '@nautiyalanuj@gmail.com' THEN 
    'nautiyalanuj@gmail.com' WHEN js_email = '.agiletestanalyst​ 
    @gmail.com' THEN 'agiletestanalyst​@gmail.com' ELSE js_email END
    WHERE
    js_email IN ("wbsirota@gmail.com","@nautiyalanuj@gmail.com",
    ".agiletestanalyst​@gmail.com");

示例如下

   UPDATE
       dbo.TestStudents
   SET
       LASTNAME = CASE WHEN LASTNAME = 'AAA' THEN 'BBB'
       WHEN LASTNAME = 'CCC' THEN 'DDD' 
       WHEN LASTNAME = 'EEE' THEN 'FFF' ELSE LASTNAME END
       WHERE
       LASTNAME IN ('AAA', 'CCC', 'EEE');