Skip to content

How would we use UNION or JOINS in SELECT queries? #17

@seojake

Description

@seojake

I'm looking to run a union query, here's what I've got:

$get_posts = $DB->query( "SELECT * FROM op_posts WHERE post_author_id IN (:ids) UNION SELECT * FROM op_post_shares WHERE share_user_id IN (:ids)", array('ids' => array(1, 2, 54)) );

But it spits out the error:
Cardinality violation: 1222 The used SELECT statements have a different number of columns

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions