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?
QtWS25 Last Chance

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 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?

    JonBJ 1 Reply Last reply
    0
    • J jdent

      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?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on 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
      1
      • JonBJ JonB

        @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 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!

        JonBJ 1 Reply Last reply
        0
        • J jdent has marked this topic as solved on
        • J jdent

          @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!

          JonBJ Online
          JonBJ Online
          JonB
          wrote on 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

          • Login

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