我正在尝试创建一个数据库视图,其中包含有关马匹的信息,更具体地说是有关马匹,其主人和寄宿生的信息。该视图必须连接三个表。我必须创建“名字,姓氏,主要电话和谷仓名称”的视图。然后,我必须联接表“ boarder,horse和boarder_horse”来创建关系。我不知道如何将各个表连接在一起。
到目前为止,这就是我所拥有的:
CREATE VIEW horse_owner
AS
SELECT b.boarder firstname, b.boarder lastname, b.boarder primaryphone,
h.horse barname
FROM boarder b
INNER JOIN horse h
ON bh.horse_id = h.id
INNER JOIN boarder_horse
ON bh.boarder_id = b.id
ORDER BY LastName DESC;
我不明白如何正确地将适当的表链接在一起。
答案 0 :(得分:0)
您有// Import node's filesystem tools
const fs = require('fs');
const path = require('path');
// variable definitions
const a = 1;
const b = 'hello';
const d = 'text';
const x = 0;
const y = [];
const z = 'hi'
const arr = [1, 2, a, b, {c: d}, [x, y, z], '1a']
// reduce goes through the array and adds every element together from start to finish
// using the function you provide
const filedata = arr.reduce((a, b) => {
// manually convert element to string if it is an object
a = a instanceof Object ? JSON.stringify(a) : a;
b = b instanceof Object ? JSON.stringify(b) : b;
return a + '\r\n' + b;
});
// path.resolve combines file paths in an OS-independent way
// __dirname is the directory of the current .js file
const filepath = path.resolve(__dirname, 'filename.txt');
fs.writeFile(filepath, filedata, (err) => {
// this code runs after the file is written
if(err) {
console.log(err);
} else {
console.log('File successfully written!');
}
});
个错误的订单。另外,您缺少别名JOIN
。试试:
bh