Skip to content

Issue with UPDATE and JOIN #427

@kennylajara

Description

@kennylajara

Hi,

I'm trying someting like this:

$data = Array (
    'a.status' => 'Unlinked',
);
$db->join("post p", "a.post_id=p.id", "INNER");
$db->where("p.id", '58');
$db->where("a.filename", 'image.jpg');
$db->where("a.status", 'Linked');
$db->where("p.status", 'Deleted', '!=');
$done = $db->update("attachment a", $data);

Im getting a query like this one:

UPDATE attachment a INNER JOIN post p on a.post_id=p.id SET `a.status` = 'Unlinked' WHERE p.id = '58' AND a.filename = 'image.jpg' AND a.status = 'Linked' AND p.status != 'Deleted'

The problem is on a.status that come with this symbol (`) on each side, when it is suppoused to be in the and after the point. So MySQL is looking for a field named 'a.status' deside a field name 'status' in table 'a'.

I need to use [a.status] and not only [status] because as you see table 'a' and table 'p' has a 'status' field and I could get this error: the Column 'status' in where clause is ambiguous.

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