WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-2008, 08:08 AM
WebProWorld New Member
 

Join Date: Nov 2007
Posts: 12
kumiko RepRank 0
Unhappy searching keywords sql

halo there, i have some sql query question need to ask.i know maybe this is quite easy for others.but i really cant figure out how to query this thing i wan since i m quite poor in database sql .
hereby i have attached an image.


first, user can insert a set of string keywords to search --> apple, orange, pear. there are 3 tables involve. by default, if user didnt check the radio button, the system will search the result from table A which consist of( photoid, photoname and photokeywords). it will match the keywords and then display out the photo name as result.
my problem is..when the user CLICK on the radio button, the system still will do the searching same as below + do another matching to search the LKeywords in the table B which consist of( lightboxid, lightboxname, and LKeywords).

if it is match, then will go to table C(lgihtboxphoptoid,lightboxid, photoid) to see tat lightbox id tat get jz now got any photos id related or not . if ther eis the photoid in the table C, then get back the photo name from the table A.

i am using ASP with MS SQL.

i realy headache to get out this result. can someone plz help me? i need help. urgent
Reply With Quote
  #2 (permalink)  
Old 01-11-2008, 09:31 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,782
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: searching keywords sql

So I take it the issue you are having is that the search is being too "greedy" - it is not confining it's search to the photokeywords field in table 1, it is also getting results from Lkeyword in table 2?

If that is the case, I would suggest checking how the database is set up. Some setups create a keyword index to optimize text searching. If this index combines both keyword fields, the problem could occur. You would need to set up a second keyword index for the second table. Unfortunately I am not quite familiar enough with MS SQL to advise further.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #3 (permalink)  
Old 01-11-2008, 06:50 PM
WebProWorld New Member
 

Join Date: Sep 2003
Location: Houston
Posts: 3
jimn RepRank 0
Default Re: searching keywords sql

Kumiko,

It is impossible to debug your problem without knowing what, exactly you are doing in your script and SQL query. There may be logic errors in your script code and/or in your SQL query.

On another issue, when you build SQL queries on the fly, you must be very careful to protect your data from an SQL Injection attack. See the following article:
SQL Injection Attacks - Are You Safe?
__________________
Jim Nech
http://www.affiliate-facts.com
Reply With Quote
  #4 (permalink)  
Old 01-11-2008, 09:11 PM
WebProWorld Veteran
 

Join Date: Aug 2006
Location: Burlington, Ontario, Canada.
Posts: 406
jtracking RepRank 1
Default Re: searching keywords sql

if you could show us the sql and i presume you want your sql to know if the radio box was selected correct???

show me the sql
__________________
Post as-it-happens crime stories of criminal behaviour at crimedigg.com
Reply With Quote
  #5 (permalink)  
Old 01-12-2008, 11:24 AM
WebProWorld New Member
 

Join Date: Nov 2005
Posts: 9
tim2005 RepRank 0
Default Re: searching keywords sql

Hi,

The simplest implementation of your task requires two queries:

1) query for search by photo keyword only
SELECT A.Photoname FROM A
WHERE A.photokeywords LIKE Search_Keyword

2) query for search by photo keyword and lightbox keyword
SELECT A.Photoname FROM
C INNER JOIN A ON C.Photoid = A.Photoid
INNER JOIN B ON C.Ligghtboxid = B.Lightboxid
WHERE A.photokeywords LIKE Search_Keyword OR B.Lkeywords LIKE Search_Keyword

If you need search keyword contained in both tables you should change OR to AND in WHERE clause:
WHERE A.photokeywords LIKE Search_Keyword AND B.Lkeywords LIKE Search_Keyword

This implementation shows the main principle and will not give the best performance. Note please that in examples above omitted keywords preparation. Search performed by one keyword only.

The exact implementation depends on MS SQL version, configuration and available features.

Better performance and flexibility will be achieved with full-text querying support.

If you have not mach data and queries number, you can use LIKE.
Reply With Quote
  #6 (permalink)  
Old 01-12-2008, 01:35 PM
WebProWorld Member
 

Join Date: Jun 2006
Location: Third Stone from the Sun
Posts: 25
John Redfield RepRank 0
Default Re: searching keywords sql

Its difficult to understand exactly what you want to happen. More detail is needed.

But from what I can gather from your post, you want the photoname included in the result from table C.

If the query joins are in place for the three tables, simply add the "photoname" to the Select Statement.

John
__________________
Peace
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum


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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is 'over searching' bad? dakster Google Discussion Forum 7 11-15-2006 11:44 AM
Searching using "keywords" in quotes Ellio Google Discussion Forum 8 12-30-2005 05:36 PM
New Keywords. Never heard before. Niche Keywords TrafficProducer Search Engine Optimization Forum 1 08-23-2005 11:25 AM
So What Are Your Searching For? WPW_Feedbot Search Engine Optimization Forum 0 07-13-2005 10:30 AM
Searching for 1?? websitepromoter Search Engine Optimization Forum 1 09-11-2004 02:14 PM


Search Engine Optimization by vBSEO 3.2.0