SQL使用重复记录连接两个不相关的表

时间:2016-02-26 11:11:48

标签: sql sql-server oracle

我有两个表,为了参数清单表A和表B,我想加入它们并生成一个结果集,表B中的每一行都有一行表。

    Table A          Table B
    NumericId        Type
    Description

    Contents of A    Contents of B
    1, Starting      Operation A
    2, Completing    Operation B
    [More rows]      [NO MORE ROWS]

    Desired result set:
    1, Starting, Operation A
    1, Starting, Operation B
    2, Completing, Operation A
    2, Completing, Operation B
    ... etc. ...
    (order is irrelevant)

这可能吗?如果是这样,pelase可以有人帮助我吗?

提前致谢。

3 个答案:

答案 0 :(得分:3)

SELECT * FROM TAbleA CROSS JOIN TableB

答案 1 :(得分:3)

user_id = fields.Many2one('res.users', 'User')

@api.model
def create(self, values)

    values['user_id'] = self.env.context.uid

    return super(YourClassName, self).create(values)

@api.multi
def write(self, values)

    if self.user_id.id != self.env.context.uid:
        raise Warning('You cant edit this document')

return super(YourClassName, self).write(values)

答案 2 :(得分:1)

我通过交叉加入解决了这个问题!

    select 
        a.NumericId, a.Description, b.Type
    from TableA a
    cross join TableB b
    order by
        a.NumericId, a.Description, b.Type

由于