0

I need to delete records from three tables at a time.Here is my query:-

$query =$this->db->query("DELETE ps_faq_categories FROM ps_faq_categories INNER JOIN ps_faqs ON('ps_faq_categories.faq_category_id = ps_faqs.faq_category_id') 
                     INNER JOIN ps_faq_comments ON('ps_faqs.faq_id = ps_faq_comments.faq_id') WHERE 'ps_faq_categories.faq_category_id' = $category_id");

I am getting error like , An expression of non-boolean type specified in a context where a condition is expected, near 'INNER'.

Youv
  • 75
  • 1
  • 5
  • 12

1 Answers1

0

remove single quote from the query

$query =$this->db->query("DELETE ps_faq_categories,ps_faqs,ps_faq_comments FROM ps_faq_categories INNER JOIN ps_faqs ON(ps_faq_categories.faq_category_id = ps_faqs.faq_category_id) 
                     INNER JOIN ps_faq_comments ON(ps_faqs.faq_id = ps_faq_comments.faq_id) WHERE ps_faq_categories.faq_category_id = $category_id");
Man Programmer
  • 5,300
  • 2
  • 21
  • 21
  • I have tried this , but havent solved am getting error, Incorrect syntax near '`' – Youv Sep 28 '15 at 07:02
  • The record deleted from ps_faq_categories but not deleting from ps_faqs and ps_faq_comments.Is their any problem in my query – Youv Sep 28 '15 at 07:10
  • Unfortunately it doesnt work , [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near ','. – Youv Sep 28 '15 at 08:35
  • the multi-part identifier "ps_faq_categories.faq_category_id" could not be bound. – Youv Sep 28 '15 at 09:20
  • i updated the query and check this link http://stackoverflow.com/questions/2214433/mysql-delete-row-from-multiple-tables it will may be help you – Man Programmer Sep 28 '15 at 10:01