» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2006, 11:00 AM
parrod parrod is offline
OSP Starters
 
Join Date: Aug 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
parrod is on a distinguished road
Default "Fuzzy" search on keys with relevance

I got three tables; house, attributes, houseattributes:

house table:

house_id
house_location

attributes table:

attrib_id
attrib_title

houseattributes:

ha_id
ha_house
ha_attrib

The idea is that I will fill up the attributes table with stuff like: white-colored, three story, two story, has cellar, has balcony, has garden and so on. I could then populate houseattributes with the house and attribute table-keys (attrib_id, house_id). So if I want to search for a house with a specific attribute, I would do:


Code:
SELECT * FROM house LEFT JOIN houseattributes ON houseattributes.ha_house.house.house_id WHERE ha_attrib = '3'

In this example, "3" is the attribute, as set in the attributes table).

Now for the problem.

I want the ability list all houses that has several attributes se -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-09-2006, 11:01 AM
gathy gathy is offline
Junior Member
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
gathy is on a distinguished road
Default

Don't use things like:
"has basement" just use "basement".

also in the houseattributes table you don't need ha_id. you don't want to look the attribute up by having to know that roof is ha_id 3.

Lets insert some test data:

Code:
house table:
1, '10 primrose'
2, '8 primrose'
3, '2 primrose'

attributes table:
1, 'roof'
2, 'double garage'
3, 'windows'
4, 'door'
5, 'deck'

house_attributes:
1, 1
1, 3,
1, 4
1, 5
2, 1
2, 2
2, 3
2, 4
3, 1
3, 3
3, 5


So now you want to know which houses have a roof and a deck, here is the basic search we would do for that:


Code:
select
house_id,
house_location,
count(*) as attributes
from house
left outer join
house_attributes
-- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The future of Internet: Real-time Web Search and the Semantic Web waqar Premium Webmaster Articles 0 10-30-2006 07:41 AM
Oracle Unveils Oracle Secure Enterprise Search 10g outsourcingplans Web Hosting Industry 0 03-03-2006 05:42 PM
Ask Jeeves Launches Proprietary Image Search Technology outsourcingplans Web Hosting Industry 0 01-26-2006 08:05 PM
Navisso Search Launches Beta Test outsourcingplans Web Hosting News 0 01-04-2006 03:58 PM
Google Personalized Search Unleashed! outsourcingplans Web Hosting News 0 12-01-2005 04:44 PM


All times are GMT. The time now is 12:12 PM.