I have the following for properties:
Code:
CREATE TABLE `properties` (
`property_id` bigint(20) unsigned NOT NULL auto_increment,
`property_title` varchar(127) default NULL,
`property_description` text,
`property_summary` varchar(255) default NULL,
`property_keywords` varchar(255) default NULL,
`property_lat` double default NULL,
`property_lon` double default NULL,
`property_beds` decimal(4,1) default NULL,
`property_baths` decimal(4,1) default NULL,
`property_sleeps` decimal(4,1) default NULL,
`property_approved` binary(1) NOT NULL default '1',
`property_active` tinyint(1) NOT NULL default '1',
`complex_id` smallint(5) unsigned default NULL,
`type_id` smallint(5) unsigned NOT NULL,
`vicinity_id` smallint(5) unsigned default NULL,
`destination_id` smallint(5) unsigned NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`property_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
And available amenities:
Code:
CREATE TABLE `amenities` (
`amenity_id` smallint(5) unsigned NOT NULL auto_increment,
`amenity_name` varchar(31) NOT NULL,
`amenity_active` tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (`amenity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
And a cross reference table:
Code:
CREATE TABLE `property_x_amenity` (
`property_id` bigint(20) unsigned NOT NULL,
`amenity_id` smallint(5) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I have an "advanced search" form that allows the user to check off all amenities they are looking for when they submit a search.
I am having trouble coming up with a way to find all properties that have ALL of the submitted amenities.
Any suggestions? If clarification is needed, let me know.
Thanks.