I am writing some code to take notes. At this point I can enter the notes and signify if they are a subchapter or a new chapter. if its a new chapter topicParent is null and if it is a subchapter topicParent is equal to the topicID of its "parent chapter".
I have two tables:
CREATE TABLE topicsTable (
topicId INT NOT NULL AUTO_INCREMENT,
topicName VARCHAR(50),
topicParent INT NULL,
PRIMARY KEY (topicID),
);
CREATE TABLE entryTable(
entryId INT NOT NULL AUTO_INCREMENT,
topicId INT,
topicBody TEXT,
PRIMARY KEY (entryId),
FOREIGN KEY (topicId) REFERENCES topicsTable (topicId)
);
What I am trying to figure out is how to place the body of the notes in the entryTable and reference it to the topicId, while placing the topicName and topicParent in the topicsTable. I guess what I am asking is whether there is a way to conjoin the INSERT statement, or if it has to be 2 statements.
???
-Jason
Inserting into multiple tables...
Moderator: General Moderators
-
poisedforflight
- Forum Newbie
- Posts: 1
- Joined: Mon Nov 07, 2005 4:07 pm
you're inserting into two tables so you will need two queries.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
-
hessodreamy
- Forum Commoner
- Posts: 58
- Joined: Wed Apr 20, 2005 8:11 am