Hey,
I have a sql syntax error, but just cant find the mistake…
CREATE DATABASE IF NOT EXISTS Postsandbuy;
USE Postsandbuy;
CREATE TABLE `posts` (
`post_id` int(10) NOT NULL,
`post_title` varchar(255) NOT NULL,
`post_content` varchar(255) NOT NULL,
`post_time` datetime NOT NULL,
`isforsale` tinyint(1) DEFAULT NULL,
`price` int(11) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`filename` varchar(255) DEFAULT NULL,
`sold_file` varchar(255) DEFAULT NULL,
`state` enum('Open','Closed') DEFAULT NULL,
`buyer_id` int(11) DEFAULT NULL,
`poster_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `users` (
`usr_id` int(10) NOT NULL,
`usr_username` varchar(255) NOT NULL,
`usr_password` varchar(255) NOT NULL,
`usr_email` varchar(255) NOT NULL,
`usr_country` varchar(255) NOT NULL,
`usr_age` int(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `abos`(
`usr_id` int(10) NOT NULL ,
`abo_id` int(10) NOT NULL,
FOREIGN KEY (usr_id) REFERENCES users(usr_id),
FOREIGN KEY (abo_id) REFERENCES users(usr_id)
)
ALTER TABLE `posts`
ADD PRIMARY KEY (`post_id`),
ADD KEY `buyer_id` (`buyer_id`),
ADD KEY `poster_id` (`poster_id`);
ALTER TABLE `users`
ADD PRIMARY KEY (`usr_id`);
ALTER TABLE `posts`
MODIFY `post_id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
ALTER TABLE `users`
MODIFY `usr_id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
ALTER TABLE `posts`
ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`buyer_id`) REFERENCES `users` (`usr_id`),
ADD CONSTRAINT `posts_ibfk_2` FOREIGN KEY (`poster_id`) REFERENCES `users` (`usr_id`);
insert into users (usr_id, usr_username) VALUES (0, "Anonymous");
Any help would be amazing…