Jump to content
Sign in to follow this  
NeoLogy

[sqlite] Camne Nak Join 2 Table Dari 2 Database?

Recommended Posts

Salam,

Aku menggunakan SQLite Database Engine dalam projek VB.NET aku..Sekarang ni, nak tanya sket pasal SQLite punye query untuk joinkan 2 table dari 2 database berlainan ke dalam satu table.

Contoh : Data dari TableA dalam DB1.db hendak dimasukkan ke dalam TableB dalam DB2.db. Kedua-dua TableA dan TableB adalah identical dari segi table structure.

Sebelum ni, aku gunakan kaedah dengan copy row by row..Kalau data sikit, xpela..Kalau berpuluh ribu..mau dekat setengah jam nak copy. So, SQL query camne yang boleh digunakan?

Aku ada google2..ada yang kata boleh guna SELECT INTO, ada yang UNION..ada yang gune SELECT..JOIN..Tapi aku kurang paham sebab kebanyakkan contoh yang diberi adalah antara table dlm satu database..ada yang combine table tu dalam table baru..so, mintak tolong otai2 kat sini..

Generalnya :

DB1.TableA --> DB2.TableB dengan cara yang terpantas..

Share this post


Link to post
Share on other sites
Salam.. Pertama sekali kena guna keyword "ATTACH", contoh

[CODE]
attach database database1.db as db1;
attach database database2.db as db2;
[/CODE]

Kemudian baru laksanakan arahan

[CODE]
INSERT INTO db1.TABLE(Id, Value1, Value2) SELECT * FROM db2.TABLE;
[/CODE]

Harap membantu... ;) Edited by Chuki2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...