本文介绍了其中是我的sql代码中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 'SELECT * FROM t1 
JOIN t2 ON t1.wid = t2.wid
WHERE t2.wid IS NULL
LIMIT'。 $ number;

此代码没有任何回报给我,您能帮我为什么我不采取价值回来

解决方案
  JOIN t2 ON t1.wid = t1.wid 

这是你的意思吗?或者你真的是t1.wid = t2.wid吗?



好的。

,所以你修复它。这不会显示任何结果,除非t2中的行具有与t1中具有相同宽度的行匹配的宽度。



如果您想要结果,请更改它到这:

 'SELECT * FROM t1 
LEFT JOIN t2 ON t1.wid = t2.wid
WHERE t2.wid IS NULL
LIMIT'。 $ number;

NEXT EDIT



如果目标是使用t2中不是ALREADY的t1更新t2,那么它将是这样:

 'INSERT INTO t2 
SELECT t1。* FROM t1
LEFT JOIN t2
ON t1.wid = t2.wid
WHERE t2.wid IS NULL
LIMIT'。 $ number;

缺少的步骤只是返回t1的结果,然后将它们插入到t2。


'SELECT * FROM t1
          JOIN t2 ON t1.wid = t2.wid
          WHERE t2.wid IS NULL
          LIMIT ' . $number;

This code nothing returns to me could you help why i do not take values back??

解决方案
JOIN t2 ON t1.wid = t1.wid

did you mean that? or do you really mean t1.wid = t2.wid? in which case you'd want a left join.

EDIT

Okay, so you fixed it. That won't show up any results unless there are rows in t2 that have a wid that matches a row in t1 with the same wid.

If you want results, change it to this:

'SELECT * FROM t1
          LEFT JOIN t2 ON t1.wid = t2.wid
          WHERE t2.wid IS NULL
          LIMIT ' . $number;

NEXT EDIT

If the goal is to update t2 with values from t1 that aren't ALREADY in t2, then it would be something like this:

'INSERT INTO t2 
   SELECT t1.* FROM t1
     LEFT JOIN t2 
        ON t1.wid = t2.wid
     WHERE t2.wid IS NULL
     LIMIT ' . $number;

The missing step was simply to return only t1's results, and then insert them into t2.

这篇关于其中是我的sql代码中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 21:09