SeoTaiJi SeoTaiJi - 1 year ago 65
iOS Question

I want to put db tables in same database. How?

My iOS program download [A.sqlite3] file in server.

My iOS have already [b.sqlite3] file in local

I want to Join A.sqlite3's table with b.sqlite3's table in local iOS.

But, because of table's database is different, I have problem joining tables.

How do I put tables in same db?

Answer Source

You can use the sqlite ATTACH syntax. Assuming you had a table A in database A.sqlite3 and a table B in database B.sqlite3, from the command line, the steps would be:

$ sqlite3 A.sqlite3
sqlite> ATTACH 'B.sqlite3' AS dbB;
sqlite> SELECT a.*,dbB.b.* FROM a,dbB.b WHERE ( =;

The ATTACH gives the additional database file a prefix which you can use in your sql statements.

On an iPhone app, you open your A.sqlite3 database as before, then pass the sql ATTACH command to the sqlite library like you pass your other sql commands, and remember to give the full pathname as the first argument to the ATTACH.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download