0

phpmyadmin で MySQL クエリを使用して 2 つのテーブルに存在する行をクロスチェックしようとしています。userID両方のテーブルで a が見つかった場合は、そのuserIDユーザー名を別のテーブルに挿入します。これが私のコードです:

INSERT INTO userswithoutmeetings
SELECT user.userID
IF('user.userID'='meeting.userID');

私はこのエラーに悩まされ続けています:

#1064 - You have an error in your SQL syntax; check the manual that corresponds
 to your MySQL server version for the right syntax to use near    
'IF('user.userID'='meeting.userID')' at line 3

私が試した他のステートメントは機能しましたが、値をテーブルに入れませんでした。

4

1 に答える 1

1

何かのようなもの

INSERT INTO userswithoutmeetings(userId,userName)
SELECT DISTINCT a.userId, a.userName
FROM table1 a 
INNER JOIN table2 b ON (a.userId = b.userId)
于 2012-11-22T17:03:20.697 に答える