Postgresql 对于具有值的列,Left Join返回null

Postgresql 对于具有值的列,Left Join返回null,postgresql,express,join,knex.js,Postgresql,Express,Join,Knex.js,我有两张桌子: 表1: id | item_id | item_name 1 | 1 | apple 表2: id | item_id | item_price 表1有一些数据,表2还没有任何数据,但我想在html表中显示它们。我希望加入这两个表以获得一个json对象: {id:1,item\u id:1,item\u name:apple,item\u price:null}。 但是我得到了这个json对象,这是不需要的:

我有两张桌子:

表1:

id  |   item_id    |   item_name
1   |      1       |     apple
表2:

id  |   item_id    |   item_price
表1有一些数据,表2还没有任何数据,但我想在html表中显示它们。我希望加入这两个表以获得一个json对象:

{id:1,item\u id:1,item\u name:apple,item\u price:null}。

但是我得到了这个json对象,这是不需要的:

{id: null, item_id: null, item_name: apple, item_price: null}
使用knexjs,这是我用来连接表的代码:

database.select ('*') from ('table1).leftJoin('table2', 'table1.item_id', 'table2.item_id').then(function(data) {
console.log(data)
};

我加入错了吗?为此,我正在使用node express服务器和postgresql数据库。我希望id和
item_id
不返回null,因为它们有值。或者除了连接表之外,还有什么方法可以从所有列中获取所有值呢?

我不知道knex.js,但我会尝试
数据库。选择('table1.*')…
我想是列名覆盖的问题。做点像-

database('table1')
.leftJoin('table2', 'table2.item_id', 'table1.item_id')
.columns([
    'table1.id',
    'table1.item_id',
    'table1.item_name',
    'table2.price'
    ])
.then((results) => {

})

请给我一个机会。谢谢兄弟。我只需要添加
.columns(['table1.*,'table2.price'])
来获取值,而不是null。