sql - How to add record for all the column in table -



sql - How to add record for all the column in table -

i have 2 tables e.g:

table1id name visitareacode 1 test1 003 2 test2 003 3 test5 004 table2id table1id bingid 1 2 2 table3 bingid 1 1 2 2 3 2

if visitareacode table1 not nowadays in table2 (by table1id) query should add together of them. in table2 bindid 1 not exists when executing query bingid 1 should linked areacode starts 003. table 2 should like:

table2id table1id bingid 1 3 2 2 1 1 3 2 1

i can utilize if not exists(select * ... add together 1 record not records.

if correctly understanding question seek this:

insert table2 (table1id, bingid) select t1.table1id, t3.bingid table1id t1, table3 t3 not exists ( select * table2 t2 t2.table1id = t1.table1id , t2.bingid = t3.bingid )

assuming table2.table2id autoincrement

sql

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -