Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to Query (join) two tables from two different sqlite databases?
Forum Updated to NodeBB v4.3 + New Features

How to Query (join) two tables from two different sqlite databases?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Binary Soft
    wrote on 4 Jan 2019, 13:32 last edited by VRonin 1 Apr 2019, 13:37
    #1

    I want to query data from two tables.

    eg.
    SELECT M.ID, M.Name, M.Year, M.Type, P.MoviePicture FROM Movie as M LEFT JOIN Movie_Image as P ON M.NO=P.NO
    Above statement is ok when two tables exist with single database.

    My Problem is table named Move is within myMove.db.
    Other table named Movie_Image is within myPicture.db.

    Hello!How to Query (join) two tables from two different sqlite databases?

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Jan 2019, 13:44 last edited by
      #2

      Hi
      Its possible via
      https://sqlite.org/lang_attach.html

      However, i have not tested if it works in connection with Qt database classes.

      1 Reply Last reply
      3
      • F Offline
        F Offline
        fcarney
        wrote on 4 Jan 2019, 15:36 last edited by
        #3

        I got to thinking about this and realized this might be a really good use of a temporary memory database. You could:

        • query the tables of each respective database
        • create a temporary memory database in sqlite
        • create 2 tables from each query of each respective table
        • do a join query on the two tables
        • use the data
        • delete the temporary memory database

        The neat thing is this should work regardless of the features of the source databases. They could even be completely different types of SQL (or even non sql) databases.

        One database to join them all and in the memory bind them...

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        1

        2/3

        4 Jan 2019, 13:44

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved