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?

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.5k Views
  • 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.
  • Binary SoftB Offline
    Binary SoftB Offline
    Binary Soft
    wrote on last edited by VRonin
    #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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on 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

        • Login

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