[odb-users] Defining a table view with inner join

Lior Tamim liorta at gmail.com
Fri Jan 19 06:36:52 EST 2018


Suppose I have 2 database tables:

CREATE TABLE developers(
    employee_id INTEGER,
    employee_name TEXT)

CREATE TABLE new_employees(
    id INTEGER,
    age INTEGER)

I wish to define a table view that contains all the *new developers*.

With simple SQL query this can be achieved easily by using inner join:
"select * from developers inner join new_employees on
developers.employee_id == new_employees.id"

What's the best way to achieve this with table view pragma?

#pragma db view table("developers" ...) // not sure how to continue this
statement
struct new_developers
{
    #pragma db column("employee_name") type("TEXT")
    std::string employee_name;
}

Thanks,
Lior


More information about the odb-users mailing list