简体   繁体   中英

How To Delete a LEFT OUTER JOIN

I am at the moment trying to delete a LEFT OUTER JOIN I created for a CMS website on PHP my LEFT OUTER JOIN looks like this:

$sqlQuery = "SELECT filename FROM phpland LEFT OUTER JOIN 
images ON phpland.image_id = images.id WHERE phpland.id = '$pageid' ";

In this case phpland and images are the name of my tables and the $pageid is the id I'm passing to it, yet it seems to work no problem but when I attempt to delete it I'm trying:

DELETE filename from phpland AS filename LEFT OUTER JOIN images 
ON phpland.image_id = images.id WHERE phpland.id = '$pid' "

Same situation Im passing the ID and I'm even echoing the ID on PHP to make sure is the ID I wish to delete but it tells me the ID is ambiguous, I'm not sure what I am doing wrong the primary Key on the table images.id is a foreign key on phpland as image_id .

I do hope this was not confusing for anyone, any type of help is highly appreciated.

Why do you reference to table images when your id to delete is already in phpland?

And your syntax for deletion is worng. Try:

DELETE FROM phpland 
WHERE phpland.id = '$pageid' 

See also http://dev.mysql.com/doc/refman/5.0/en/delete.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM