Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't know if this will solve your problem because your insert statements reference two other tables (<code>person</code> and <code>groups</code>) which are not shown in your code (so I have no idea what's going with those tables).</p> <p>But, since you wrote</p> <blockquote> <p>Any help on this is appreciated as this is holding critical biz work.</p> </blockquote> <p>... here's some help / suggestions:</p> <p>I'm not sure how those tables are being <em>successfully</em> created because I get a lot of errors when I try that code (but that's beside the point), however here's a more efficient method (<strong>Note</strong>: I can only assume the references to the tables <code>person</code> and <code>groups</code> means that those tables already exist):</p> <p><strong>EDIT</strong>: Try this first, after creating the tables:</p> <pre><code>FLUSH TABLES; ALTER TABLE `comment` AUTO_INCREMENT = 1; ALTER TABLE `post` AUTO_INCREMENT = 1; </code></pre> <p>If that doesn't help, here's the more efficient method as mentioned above:</p> <pre><code>CREATE TABLE `comment` ( `id` int(11) NOT NULL AUTO_INCREMENT, `p_id` int(11) DEFAULT NULL, `person_id` int(11) DEFAULT NULL, `comment` varchar(2000) DEFAULT NULL, PRIMARY KEY (`id`), KEY `p_id` (`p_id`), KEY `person_id` (`person_id`) ); CREATE TABLE `post` ( `id` int(11) NOT NULL AUTO_INCREMENT, `group_id` int(11) DEFAULT NULL, `post` varchar(2000) DEFAULT NULL, `person_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `group_id` (`group_id`), KEY `person_id` (`person_id`) ); ALTER TABLE `comment` ADD CONSTRAINT `comment_fk_1` FOREIGN KEY (`p_id`) REFERENCES `post` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `comment` ADD CONSTRAINT `comment_fk_2` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `post` ADD CONSTRAINT `post_fk_1` FOREIGN KEY (`person_id`) REFERENCES `comment` (`person_id`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `post` ADD CONSTRAINT `post_fk_2` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE; </code></pre>
 

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