473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Select not returning all results

Hi everyone,
I am using a PERL script and am having some probs with it....

Expand|Select|Wrap|Line Numbers
  1. $query = sprintf (
  2.                "SELECT `Cats`.`Name`,`Address`.`Address`,`Address`.`City`,`Contact`.`Phone`
  3.                 FROM
  4.                 (
  5.                 `Cats`
  6.                     LEFT JOIN
  7.                         `Address`
  8.                             USING (`Name`)
  9.                     LEFT JOIN
  10.                          `Contact`      
  11.                             USING (`Name`) 
  12.                 )
  13.                 WHERE
  14.                 `Cats`.`Category` LIKE '%$search%' 
  15.                 ORDER BY name LIMIT %d,%d",
  16.                 $start - 1,         # number of records to skip
  17.                 $per_page + 1);     
  18. }  
Of course the actual script is much longer, but I believe the problem is in here somewhere....

In my DB, I have the following entry:

Middle River Restorations, LLC
Furniture Repair
Furniture Repair, Restoration, Stripping, Refinishing, Chair Canning & Weaving, Residential & Commercial, Moving, Flood and Fire Damage insurance, Custom Fireplace Mantels

If I do a search for 'furniture' or 'furniture repair' I get nothing, if I search for 'repair' it comes up..... BTW in the quoted text above, the first line is name, the second is category and the third is keywords and I am searching on category.

This is driving me nucking futz.....

Any suggestions? I can/will post more of the code if needed.

Thanks!
Jim
Oct 14 '07 #1
2 1489
pbmods
5,821 Expert 4TB
Heya, Jim.

Now I see why you had pairs of percent signs in your other post.

You'll probably want to change it to something like this:
Expand|Select|Wrap|Line Numbers
  1. LIKE '%%%s%%'
And then add $search to the parameters for sprintf().
Oct 14 '07 #2
Heya, Jim.

Now I see why you had pairs of percent signs in your other post.

You'll probably want to change it to something like this:
Expand|Select|Wrap|Line Numbers
  1. LIKE '%%%s%%'
And then add $search to the parameters for sprintf().
Ok, forgive my ignorance on this, but could you please explain???

BTW..... It seems to only not give me anything when the search results contain only one entry. If I do a search for 'Fundraising' which I only have 1 entry for in the DB, I get nada, if I do a search for 'Real Estate' which I have several of in the DB, no problems.....

Strange.....
Oct 15 '07 #3

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

Similar topics

14
by: CJM | last post by:
I have a query which produces different results in the Access query builder and in an ASP page (via ADO) An example of the query is: ----------------------------------------------------------...
9
by: Rowland Hills | last post by:
I have a table which is returning inconsistent results when I query it! In query analyzer: If I do "SELECT * FROM TABLE_NAME" I get no rows returned. If I do "SELECT COL1, COL2 FROM...
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
4
by: Bill Moran | last post by:
I'm having a little trouble understanding how to do something. I assume I'm just missing it in the documentation, so a pointer to relevent docs would be as welcome as a direct answer. I have a...
1
by: TechBoy | last post by:
In VB6 I have this code for returning data to a recordset via 2 Selects: 1. Select * from MyTable (98 rows of data are here) rs.recordcount returns "98" 2. Select count(*) from MyTable...
6
by: ronchese | last post by:
Hi. I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working! In one of my tests, I have a datatable with 1 row and...
2
by: Birky | last post by:
Assign the output of a select to a variable? I am unable to find a way to assign the results of an SQL statement to a variable. I know how to assign the SQL statement to a variable but again no...
2
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT...
1
bilibytes
by: bilibytes | last post by:
hi, i was wondering if it is possible to make a SELECT query with some optional fields. i have "Object", "Info", "Image" Tables the object contains the id and name of objects, the info...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.