MySQL Add Data Based on Unique ID -


i've been looking around answer mysql query question have not been able find answer. appreciated... ps. i'm beginner.

issue: have 2 tables, 1 main table several columns , unique id column (sequential numbers) key. table has had rows of data deleted not needed. remaining id example 1,3,5,7 etc.

i have second table 2 columns, 1 being unique ids (key) , 1 text. both tables belonged same table, second 1 extracted , stored while first 1 worked on; have same ids (key). table still has ids 1,2,3,4,5,6,7 etc.

i want add the column text second table, , match rows same id on first table. text second table not have matching key first table should omitted.

table illustration

table 1
id field 1 (here want text table 2; matching ids)
1 bla
3 bla
5 bla
7 bla

table 2
id text
1 bla
2 bla 3 bla 4 bla 5 bla 6 bla 7 bla

i appreciate writing query.

thank you, patrik

you can simple join. rows exist same id in both tables retrieved:

select t1.id, t2.text table1 t1 inner join table2 t2 on (t2.id = t1.id) 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -