python - inserting three columns in a table at a time in mysql using select and values -
i need insert in 3 columns of table in mysql @ time. first 2 columns inserted selecting data other tables using select statement while third column needs inserted directly , doesn't need select. don't know syntax in mysql. pos array , need insert simultaneously. here sql command in python. sql="insert quranic_index_2(quran_wordid,translationid,pos) select quranic_words.wordid,quran_english_translations.translationid quranic_words, quran_english_translation quranic_words.lemma=%s , quran_english_translations.verse_no=%s , quran_english_translations.translatorid="%s,values(%s)"
data=l,words[2],var1,words[i+1]
r=cursor.execute(sql,data)
data passing variables in variables stored. words[i+1] holds values pos.
try using below sample query :
insert table_name(field_1, field_2, field3) values ('value_1', (select value_2,from user_table ), 'value_3')
Comments
Post a Comment