Code:
DROP TABLE IF EXISTS Author {
author_id INT NOT NULL AUTO_INCREMENT;
author_name VARCHAR(50);
PRIMARY KEY(author_id);
}
DROP TABLE IF EXISTS Joke {
joke_id INT NOT NULL AUTO_INCREMENT;
joke_title VARCHAR(20);
joke_message VARCHAR(1024);
PRIMARY KEY(joke_id);
FOREIGN KEY(author_id);
INDEX(joke_title);
}
that will create both of your tables and make the primary keys and it will index the joke_title, which if you choose to set up the site with a "search" bar will allow the user to search for a title.
ceiling of 20 characters - title 1024 characters - message
Code:
INSERT INTO table name VALUES(values);
NOTE: seperate values by commas( , )
that is all good and dandy if you want to insert a whole row into the database, but if you want to only insert a specific field in a record use
Code:
INSERT INTO table name(col1,col2) VALUES(value1, value2);
also, I suggest you take a look at the Official MySQL Manual
Bookmarks