473,499 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having trouble with MyQSL Queries

DTeCH
23 New Member
I have a heavy database with file information... this info includes file names, age of files, posters, & what have you.

My problems come from returning results with the "LIKE", or "REGEXP" functions.

Here is an example of records:

Title
Size
Date Posted
Poster

Way.Of.The.Panda.2010.DVDRip.XviD-HVK
768.96 MB
Fri, 26 Mar 2010 23:29:02 +0000
vivalaboobs

Despicable.Me.2010.SLOSiNH.DVDRip.XviD-PANDA
756.95 MB
Thu, 10 Feb 2011 10:47:03 +0000
dudek@localhost (dudek)

Kung.Fu.Panda.2.2011.TS.V2.XViD-EP1C
1.6 GB
Tue, 14 Jun 2011 03:19:19 +0000
knowinservers.com (fbi@thedoor.brb)

Chop.Kick.Panda.2011.NTSC.DVDR-STOCK
1.92 GB
Tue, 05 Jul 2011 06:38:44 +0000
HickDead

Secret.Origin.The.Story.of.DC.Comics.2010.NTSC.DVD R-SADPANDA
3.97 GB
Sat, 04 Jun 2011 11:45:40 +0000
HickDead


I have tried the LIKE statement first:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM p_search WHERE sTITLE LIKE '" & sQuery0 & "' ORDER BY tid DESC LIMIT 100;"
  2.  

sQuery0 is the search term passed in by the user, & it is fixed like this (VB.NET):
Expand|Select|Wrap|Line Numbers
  1. sQuery0 = "%" & sQuery0.Replace(" ", "%") & "%"
  2. sQuery0 = sQuery0.Replace("'", "")
  3.  
sQuery0 has all of it's Space characters replaced with the % symbol to represent any number of characters, & it's single quote characters stripped away. So... Secret Origin' Story DC Comics would become %Secret%Origin%Story%DC%Comics%, & this would be the final query term from the user.


This works (Partially)...

If i search for Kung Fu Panda, nothing is returned. (%Kung%Fu%Panda%)

If I try Kung Panda, Nothing is returned. (%Kung%Panda%)

But if I try ung Panda or ung Fu Panda, I get results. (%ung%Panda%) or (%ung%Fu%Panda%)... removing the K from Kung.

I understand that the % character means MORE than 0 characters, so it cannot be used, because Cars 2 will not be found by (%Cars%2%) query becuse it is looking for more than Cars like XCars 2 DVDRip, so the query will have to be altered to something like (%ars%2%). This cannot be used because it will return a lot of un-wanted results as well.


I then tried REGEXP like this:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM p_search WHERE sTITLE REGEXP '" & sQuery0 & "' ORDER BY tid DESC LIMIT 100;"
  2.  

sQuery0 is the search term passed in by the user, & it is now fixed like this (VB.NET):
Expand|Select|Wrap|Line Numbers
  1. sQuery0 = sQuery0.Replace(" ", "*")
  2. sQuery0 = sQuery0.Replace("'", "")
  3.  
It no longer places a character at the start, & end of the query (*), it now just replaces the space characters with the * character to represent any number of characters, but still strips away the single quote character. So... Secret Origin' Story DC Comics would become Secret*Origin*Story*DC*Comics, & this would be the final query term from the user.


This does not work at all.

If i search for Kung Fu Panda, nothing is returned. (Kung*Fu*Panda)

If I try Kung Panda, Nothing is returned. (Kung*Panda)

But if I try Panda, I get results. (Panda)... anything containing the word Panda is returned. maybe because there are no * characters in the final query?

I am at a loss. I am in no way a guru, or a regex master... I'm not even a noob. I'm 10 feet below that.

Can someone please give me an example of the proper way to get the results of ALL records that match the user's entry, taking into account that users will not always enter single word queries like Panda?

Thank you guys.
Sep 9 '11 #1
1 1427
js1987
2 New Member
If you are searching for Kung Fu Panda, then this query would work:

strSQL = "SELECT * FROM p_search WHERE sTITLE LIKE '%Kung%' AND
sTITLE LIKE '%Fu%' AND
sTITLE LIKE '%Panda%'
ORDER BY tid DESC LIMIT 100;"

So you need to replace your spaces in the query by AND <tablename> LIKE '%<word>%'
Sep 12 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2574
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
2
2510
by: ed | last post by:
i'm having trouble with a form. I want to be able to type in the address of the form with the data for the form items in the URL (ie: http://somesite.com/formpage.html?field1=data1&field2=data2)....
1
1782
by: Lauren Wilson | last post by:
I'm having trouble with the Access VBA help on my installation of A2K with Dev tools. Every time I try to retrieve help for items listed in the Object Browser (and SOME other items as well),...
2
4519
by: Jozef | last post by:
Hello, I am trying to put together a module and open a workspace on a database that has a simple password (using Access XP). This is the lin that I'm having trouble with; Set wrk =...
0
1519
by: Jozef | last post by:
Hello, I'm having trouble with the download links on my web server. The error I'm getting is; CGI Timeout The specified CGI application exceeded the allowed time for processing. The server...
1
1603
by: Jozef | last post by:
Hello. I'm having trouble creating a blank solution (and ASP.net web application) from my laptop. I own the server (in fact it's sitting right next to me) and have added the URL to the trusted...
1
5120
by: MLH | last post by:
Am having trouble with the filter property setting below. Would like to filter the listing to car makes beginning with "D". I'm blowing it on the filter spec somehow??? Sub OpenRecordsetX() ...
2
1729
by: Jake Barnes | last post by:
I've read over the documentation for these effects: http://wiki.script.aculo.us/scriptaculous/show/CombinationEffectsDemo I want to include them on my page. I tried attaching using onload, but...
0
1833
by: harry12 | last post by:
Hello- I'm fairly new at using Microsoft Access and I'm having trouble getting a couple of things to work in my database. The first is that I have yet to find a way to get an append query to...
2
1999
by: Stu | last post by:
Hi guys, I've been having trouble getting the clock function to work portably, please could I get some thoughts? <Possibly OT comments> It works fine on my laptop (under WinXP) and on my...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.