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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -