I have three tables: pages, blocks and pages_blocks.
My database schema looks as follow:
What would be the perfect SQL code to grab the "left" and "right" blocks for a specific page?Code SQL:
CREATE TABLE `blocks` ( `id` SMALLINT(6) NOT NULL AUTO_INCREMENT, `name` CHAR(40) NOT NULL, `content` text NOT NULL PRIMARY KEY (`id`) ); CREATE TABLE `pages` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `title` CHAR(100) NOT NULL, `content` mediumtext NOT NULL PRIMARY KEY (`id`) ); CREATE TABLE `pages_blocks` ( `page_id` INT(11) DEFAULT NULL, `block_id` SMALLINT(6) DEFAULT NULL, `location` enum('left','right') DEFAULT NULL, `display_order` SMALLINT(6) DEFAULT NULL );
Your help is much appreciated.