Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL DELETE with JOIN
    primarykey
    data
    text
    <p>Why the following query doesn't work? What is the best way to delete the following five tables row in SQL? How can I fix it?</p> <pre><code>//$id = $this-&gt;input-&gt;post('id'); $id = '65'; $this-&gt;db-&gt;query(" DELETE table_1, table_2, table_3, table_4, table_5 FROM table_1 JOIN table_2 ON table_1.id = table_2.rela JOIN table_3 ON table_2.h_id = table_3.h_id JOIN table_4 ON table_1.id = table_4.rela JOIN table_5 ON table_2.h_id = table_5.h_id WHERE table_1.id =".floor($id)); </code></pre> <p><strong>Update:</strong></p> <p><strong>table_1.id</strong> => this have id <code>65</code><br> <strong>table_2.rela</strong> => this have rela <code>65</code><br> <strong>table_2.h_id</strong> => this have h_id <code>11</code><br> <strong>table_3.h_id</strong> => this have h_id <code>11</code><br> <strong>table_4.rela</strong> => this have rela <code>65</code><br> <strong>table_5.h_id</strong> => this have h_id <code>11</code><br></p> <p><strong>Update 2:</strong></p> <p>in <code>table_1.id</code> one row have <code>65</code> and also is for <code>table_2</code> and <code>table_4</code> that have <code>rela 65</code> (<code>table_1.id = table_2.rela =&gt; 65 = 65, table_1.id = table_4.rela =&gt; 65 = 65</code>) now in <code>table_2</code> we have a column name h_id that have number <code>11</code> and it is set with <code>h_id</code> in other tables[<code>table_3</code>, <code>table_5</code>].</p> <p>How with there this relationship can get a <code>id</code> from <code>table_1</code> and delete other rows in their tables.</p> <p>i mane is this: (with have one <code>id</code> from <code>table_1</code> we can delete other rows relationship with it in their tables, in following is a example from this relationship)</p> <blockquote> <p><code>table_1.id</code> = <code>65</code> => <code>table_4.rela</code> = <code>65</code> => <code>table_2.rela</code> = <code>65</code> <strong>-></strong> <em><code>table_2.h_id</code></em> = <code>11</code> => <code>table_3.h_id</code> = <code>11</code> => <code>table_5.h_id</code> = <code>11</code>.</p> </blockquote> <p><strong>UPDATE 3:</strong></p> <p><strong>Who can help me for my problem, there is a guy? I don't get still answers for Question's.</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload