0

I have two tables like: Person (Id, Name, JobID, Age) Jobs (Id, Company, Salary)

I'm using a SqlRelationalTableModel and it's working with the following QSqlRelation:

   model-> setTable("Person")
   model-> setRelation(2,QSqlRelation("Jobs", "Id", "Company"))

My problem is that now I want to show only the jobs with salaries over 50000 and I don't know how to filter Jobs table to do it since setFilter only affects Person table.

1 Answers1

0

You can use QSqlQueryModel

QSqlQueryModel* model = new QSqlQueryModel();
model->setQuery("select * from Person left join Jobs on Person.JobID=Jobs.Id where Salary>50000");
mugiseyebrows
  • 4,138
  • 1
  • 14
  • 15