0

query

DELETE `contact`
FROM `contact` ct
INNER JOIN `contact_user` cu ON cu.contact_id=ct.id
WHERE ct.id=4 && ct.block_id=5671 && cu.user_id=1

error

Fatal: SQLSTATE[42S02]: Base table or view not found: 1109 Unknown table 'contact' in MULTI DELETE; SQL: DELETE contact FROM contact ct INNER JOIN contact_user cu ON cu.contact_id=ct.id WHERE ct.id=4 && ct.block_id=5671 && cu.user_id=1

2 Answers 2

4

Since you have defined Alias name to your table contact you need to use alias name instead of original table name. Try this

DELETE ct 
FROM   contact ct 
       INNER JOIN contact_user cu 
               ON cu.contact_id = ct.id 
WHERE  ct.id = 4 
       AND ct.block_id = 5671 
       AND cu.user_id = 1 

or remove the alias name for contact table

DELETE contact 
FROM   contact 
       INNER JOIN contact_user cu 
               ON cu.contact_id = contact.id 
WHERE  contact.id = 4 
       AND contact.block_id = 5671 
       AND cu.user_id = 1 
Sign up to request clarification or add additional context in comments.

Comments

4

Because you have defined an alias for the table, you should use it. Also replace && with and.

DELETE `ct` --`contact`
FROM `contact` ct
INNER JOIN `contact_user` cu ON cu.contact_id=ct.id
WHERE ct.id=4 and ct.block_id=5671 and cu.user_id=1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.