Jump to content

Insert login name from a table into another table, But don't if it exists.


gergy008

Recommended Posts

I think you're looking for not in

INSERT INTO `gaming` ('login') SELECT `login` FROM `users` WHERE `login` not in (SELECT `login` FROM `gaming`)

 

Sorry it is saying syntax error, I think it might be where the ('login') is, But I have no idea. Anyone have any ideas why it says syntax error?

Link to comment
Share on other sites

Because login is a column and if they are denoted they need to be denoted by back ticks ( ` ) and not single quotes ( ' ). Fixing that should get it to work (I tested a similar version on my server).

 

INSERT INTO `gaming` (`login`) SELECT `login` FROM `users` WHERE `login` not in (SELECT `login` FROM `gaming`)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.