1. <i id='ox9uu'><tr id='ox9uu'><dt id='ox9uu'><q id='ox9uu'><span id='ox9uu'><b id='ox9uu'><form id='ox9uu'><ins id='ox9uu'></ins><ul id='ox9uu'></ul><sub id='ox9uu'></sub></form><legend id='ox9uu'></legend><bdo id='ox9uu'><pre id='ox9uu'><center id='ox9uu'></center></pre></bdo></b><th id='ox9uu'></th></span></q></dt></tr></i><div id='ox9uu'><tfoot id='ox9uu'></tfoot><dl id='ox9uu'><fieldset id='ox9uu'></fieldset></dl></div>

      <small id='ox9uu'></small><noframes id='ox9uu'>

    2. <tfoot id='ox9uu'></tfoot>

          <bdo id='ox9uu'></bdo><ul id='ox9uu'></ul>
        <legend id='ox9uu'><style id='ox9uu'><dir id='ox9uu'><q id='ox9uu'></q></dir></style></legend>

        插入前检查重复项

        Check for duplicates before inserting(插入前检查重复项)

              <small id='z20FD'></small><noframes id='z20FD'>

              <tfoot id='z20FD'></tfoot>
              1. <i id='z20FD'><tr id='z20FD'><dt id='z20FD'><q id='z20FD'><span id='z20FD'><b id='z20FD'><form id='z20FD'><ins id='z20FD'></ins><ul id='z20FD'></ul><sub id='z20FD'></sub></form><legend id='z20FD'></legend><bdo id='z20FD'><pre id='z20FD'><center id='z20FD'></center></pre></bdo></b><th id='z20FD'></th></span></q></dt></tr></i><div id='z20FD'><tfoot id='z20FD'></tfoot><dl id='z20FD'><fieldset id='z20FD'></fieldset></dl></div>

                  <tbody id='z20FD'></tbody>
                <legend id='z20FD'><style id='z20FD'><dir id='z20FD'><q id='z20FD'></q></dir></style></legend>
                  <bdo id='z20FD'></bdo><ul id='z20FD'></ul>

                  本文介绍了插入前检查重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在插入数据库之前,我使用以下代码检查重复项.对我来说,只有当 namedescriptionpricecity 时,重复才被视为重复>enddate 匹配.

                  Before inserting into the database, I'm using the following code to check for duplicates. To me, a duplicate is only considered a duplicate when name, description, price, city, and enddate match.

                  foreach($states_to_add as $item) {
                      $dupesql = "SELECT 
                                      COUNT(*) 
                                  FROM 
                                      table 
                                  WHERE 
                                      (   
                                          name = '$name' 
                                          AND description = '$description' 
                                          AND manufacturer = '$manufacturer' 
                                          AND city ='$city' 
                                          AND price = '$price' 
                                          AND enddate = '$end_date'
                                      )";
                  
                      $duperaw = mysql_query($dupesql);
                  
                      if($duperaw > 0) {
                          echo nl2br("$name already exists in $city 
                  ");
                      } 
                      else {
                          $sql = "INSERT INTO table (..... (here go the values to be inserted)
                          ....
                  

                  每个值都是在运行此检查之前定义的,我的结果总是在项目已经存在时返回.我转储了dupesql"并将命令复制/粘贴到 phpmyadmin 中,返回计数为 0.

                  Each value is defined prior to running through this checking, my result always comes back as item already exists. I dumped "dupesql" and copy/pasted the command into phpmyadmin which comes back with count 0.

                  推荐答案

                  您想要执行以下操作:

                  $dupesql = "SELECT * FROM table where (name = '$name' AND description = '$description' AND manufacturer = '$manufacturer' AND city ='$city' AND price = '$price' AND enddate = '$end_date')";
                  
                  $duperaw = mysql_query($dupesql);
                  
                  if (mysql_num_rows($duperaw) > 0) {
                    //your code ...
                  }
                  

                  查看这里了解更多信息.

                  这篇关于插入前检查重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <bdo id='8KtSY'></bdo><ul id='8KtSY'></ul>
                    <legend id='8KtSY'><style id='8KtSY'><dir id='8KtSY'><q id='8KtSY'></q></dir></style></legend>

                          <tfoot id='8KtSY'></tfoot>

                          <small id='8KtSY'></small><noframes id='8KtSY'>

                        • <i id='8KtSY'><tr id='8KtSY'><dt id='8KtSY'><q id='8KtSY'><span id='8KtSY'><b id='8KtSY'><form id='8KtSY'><ins id='8KtSY'></ins><ul id='8KtSY'></ul><sub id='8KtSY'></sub></form><legend id='8KtSY'></legend><bdo id='8KtSY'><pre id='8KtSY'><center id='8KtSY'></center></pre></bdo></b><th id='8KtSY'></th></span></q></dt></tr></i><div id='8KtSY'><tfoot id='8KtSY'></tfoot><dl id='8KtSY'><fieldset id='8KtSY'></fieldset></dl></div>
                            <tbody id='8KtSY'></tbody>