mysql - Add user if not exists in another table -


i need add usernames users_waiting table if not added users table before.

var usernamesarray = ['test', 'test2']; connection.query('replace users_waiting (username) values ?', [usernamesarray]); 

i'm using node.js mysql client , have no idea how that.

you have many options of doing it. 1 of not exists() :

insert <table2> (...) select .... <source> t not exists(select 1 <table1> s                  t.id = s.id); 

i don't think it's need. can figure out rest this.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -