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 Answer 1

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");
Sign up to request clarification or add additional context in comments.

1 Comment

What if I still need to support updates on the table?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.