Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 26th, 2003, 11:11 PM
javaq javaq is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 6 javaq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How to implement 'search' similar to Google

I am using Oracle9iR2 / JDBC. I need to implement a search facility similar to google.com on the database I have. There are 20 tables in the database and around 30000 records in total. I have to search only in VARCHAR2 and CLOB fields. Each table has an ID (PK) column. How to write a single query that search these tables for given string.

Here is a sample for quick understanding...
...................................................................

CREATE TABLE A (ID NUMBER, TITLE VARCHAR2(200), DESCRIPTION CLOB);
CREATE TABLE B (ID NUMBER, TITLE VARCHAR2(200), DESCRIPTION CLOB, NOTES VARCHAR2(500));

INSERT INTO A VALUES(101, 'Best online shop', 'Amazon.com is one of the best online book store');
INSERT INTO A VALUES(102, 'Movie of the week', 'Beautiful Mind featuring...');
INSERT INTO B VALUES(201, 'Page available', 'The page is currently unavailable', 'no notes');
INSERT INTO B VALUES(202, 'Address bar', 'type the page address in the Address bar', 'store');

Here is what I am trying... (Please correct)
....................................................................
SELECT ID, TEXT
FROM (SELECT ID, (TITLE || ' ' || DESCRIPTION) TEXT
FROM A
WHERE UPPER(TITLE) LIKE UPPER('%store%')
OR UPPER(DESCRIPTION) LIKE UPPER('%store%')
)
UNION
SELECT ID, TEXT
FROM (SELECT ID, (TITLE || ' ' || DESCRIPTION || ' ' || NOTES) TEXT
FROM B
WHERE UPPER(TITLE) LIKE UPPER('%store%')
OR UPPER(DESCRIPTION) LIKE UPPER('%store%')
OR UPPER(NOTES) LIKE UPPER('%store%')
)

When I run the individual part of above query it runs fine but after UNION it gives
SELECT ID, TEXT
*
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected - got CLOB

How to solve the problem. ****OR*** Please suggest RIGHT way of doing the search (similar to google).

Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > How to implement 'search' similar to Google


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT