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. What is the best way to display a Join between 2 or 3 tables? QSqlQueryModel?

What is the best way to display a Join between 2 or 3 tables? QSqlQueryModel?

Scheduled Pinned Locked Moved Solved General and Desktop
sql
4 Posts 2 Posters 323 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.
  • J Offline
    J Offline
    jdent
    wrote on 7 Mar 2024, 07:51 last edited by
    #1

    I want to display a join of 2 or more tables selecting which columns I want to display and in what order...
    Is QSqlQueryModel the way ... is there an example?

    J 1 Reply Last reply 7 Mar 2024, 09:59
    0
    • J jdent
      7 Mar 2024, 07:51

      I want to display a join of 2 or more tables selecting which columns I want to display and in what order...
      Is QSqlQueryModel the way ... is there an example?

      J Offline
      J Offline
      JonB
      wrote on 7 Mar 2024, 09:59 last edited by
      #2

      @jdent
      Yes, QSqlQueryModel is the way to do this.

      Don't know what you need an "example" for --- just call setQuery() with whatever query you want, presumably including JOIN(s), what else is there to say? If you really want do a Google for qsqlquerymodel join and have a look through some of the matches.

      J 1 Reply Last reply 7 Mar 2024, 15:47
      1
      • J JonB
        7 Mar 2024, 09:59

        @jdent
        Yes, QSqlQueryModel is the way to do this.

        Don't know what you need an "example" for --- just call setQuery() with whatever query you want, presumably including JOIN(s), what else is there to say? If you really want do a Google for qsqlquerymodel join and have a look through some of the matches.

        J Offline
        J Offline
        jdent
        wrote on 7 Mar 2024, 15:47 last edited by
        #3

        @JonB Ok, I thought there was more explicit support for joins, but it appears we only place the query string and that's it

        Thanks anyway!

        J 1 Reply Last reply 7 Mar 2024, 18:47
        0
        • J jdent has marked this topic as solved on 7 Mar 2024, 15:48
        • J jdent
          7 Mar 2024, 15:47

          @JonB Ok, I thought there was more explicit support for joins, but it appears we only place the query string and that's it

          Thanks anyway!

          J Offline
          J Offline
          JonB
          wrote on 7 Mar 2024, 18:47 last edited by
          #4

          @jdent said in What is the best way to display a Join between 2 or 3 tables? QSqlQueryModel?:

          Ok, I thought there was more explicit support for joins

          Yes, there isn't :) Qt provides low-ish level support for database table access, nothing fancy, nothing for an arbitrary JOIN. The only "extra" is QSqlRelationalTableModel Class, which implements a specific JOIN for a foreign key. There will be third-party code, e.g. KDAB, out there which builds another layer on top if you want it.

          1 Reply Last reply
          0

          1/4

          7 Mar 2024, 07:51

          • Login

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