mysql - Sequelize join multiples fields - multiples tables -
can convert query below sequelize? set simple example illustrate idea, compare same table more 1 table. tablec.field_4 = tableb.field_4 , tablec.field_1 = tablea.field_1 , ( tablea.field_8 = 1 or tablec.field_4 not null )
var tablea = sequelize.define('tablea', field_1 : { type : sequelize.bigint, primarykey : true, autoincrement : true }, field_2 : { type : sequelize.bigint, }, field_3 : { type : sequelize.bigint(4), references : { model : 'tabled', key : 'field_3' } }, field_8 : { type : sequelize.boolean, allownull : false, defaultvalue : true }, { tablename : 'tablea' } ); var tableb = sequelize.define('tableb', { field_4 : { type : sequelize.bigint(4), primarykey : true, autoincrement : true }, field_3 : { type : sequelize.bigint(4), references : { model : 'tabled', key : 'field_3' }, allownull : false }, field_5 : { type : sequelize.string(255), unique : true, allownull : false }, field_6 : { type : sequelize.string }, field_7 : { type : sequelize.bigint, allownull : false }, { tablename : 'tableb' } ); var tablec = sequelize.define('tablec', { field_4: { type: sequelize.bigint(4), primarykey: true references: { model: 'tableb', key: 'field_4' } }, field_1: { type: sequelize.bigint, primarykey: true references: { model: 'tablea', key: 'field_1' } }, { tablename: 'tablec' } ); select * tablea join tableb on tableb.field_3 = tablea.field_3 left join tablec on tablec.field_4 = tableb.field_4 , tablec.field_1 = tablea.field_1 ( tablea.field_8 = 1 or tablec.field_4 not null ) , tableb.field_7 = 10 , tablea.field_2 = 1036
Comments
Post a Comment