Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Search Does Not Match Properly


i had created a search function on a web application.

the problem is, i try enter some of info to it, certain text can be found but certain text can be match although they are in database.

this my query:

$keywordu = strupper($keyword);
$keywordl = strlower($keyword);

$sql = "SELECT E.* FROM employes AS E, dvi_problem AS DV WHERE AS.empId = DV.empId AND (E.emp_name LIKE '%".$keyWordl."%' OR DV.reference LIKE '".$keywordi."''%".$keywordl."%' OR E.emp_name = '%".$keywordu."%' OR DV.reference LIKE '%".$keywordu."%')"

$query = mysql_query($sql, $db) or die('Fail to search.');

i test with direct copy the data from database, some string i copy can search it but some other string i copy direct it can work wo...

i try show out the variable $sql value, it show with not error, the keywordu n keywordl aslo show out the value when i print out the $sql variable.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
MATCH Fulltext Search
I am doing a search now where I have a statement "FirstName LIKE
'%$firstname%' OR JobTitle LIKE '%$jobtitle%'

how can I do the same statement using full text search, for example
with fulltext I would say MATCH (FirstName) AGAINST ('$firstname') OR
MATCH (JobTitle) AGAINST ('$jobtitle)
But that doesnt work, what is the correct way to do this query?

Using Match() For Fulltext Search
i have a table that three columns, id, url, description. this is my sql.

select id, url from search where match(description) against  ('oracle application server') limit 20

when i try this sql, it is really fast, but it doesn't return record set that contains these three words in order, 'oracle application server'.  so i tried
match(description) against  ('"oracle application server"' in boolean mode) limit 20,  but it takes kind of long. and for description like '%oracle application server%', it takes forever.

I want to return record set that contains three words in  order and then any words.

i am using Java to implement this. so i am just wondering if there is any better to solve this issue.

Search Columns For Match
I need a query syntax or command line to search all tables for a column name like 'whatever%';
I needing to search all tables in a database for column names that match without listing each table name, a global table search.

MATCH Boolean Search
Recently my search engine stopped working... instead of searching and matching queries in boolean mode... it just grabs EVERYTHING and displays it... I'm thinking that my host must have turned something off, It has MySQL 4+ running and it used to work flawless.

MATCH () Boolean Search
My MySQL Database has recently started acting up, my search engine, instead of returning just relevent results, prints ever since entry in my database without regards to what criteria was given.here is a sample code that just brings up EVERY article in my DB, even though only abou 20 of them mention the word tetris.


Code:

SELECT title FROM articles WHERE MATCH (articletext) AGAINST ('tetris' IN BOOLEAN MODE);

Mysql Search Will Not Match Some Words
I have a query which has work perfectly well for years but a slight anomaly has been discovered when the below query is run to match either the word take or five, there are no results even though the words do appear where the search is conducted.
take and five are not reserved words as far as I know so why would this happen?

SELECT PAGES.handle, ACCOUNTS.business, ELEMENTS.element_content,
MATCH (
ELEMENTS.element_content
)
AGAINST (
'take'
) AS score
FROM portal_pages AS PAGES, portal_pages_elements AS ELEMENTS, portal_accounts AS ACCOUNTS
WHERE MATCH (
ELEMENTS.element_content
)
AGAINST (
'take'
)
AND PAGES.id = ELEMENTS.page_id
AND ELEMENTS.element_name = 'body'
AND ACCOUNTS.id = PAGES.account_id
ORDER BY score DESC
LIMIT 0 , 30

Search Question In MySQL (without Match)
using InnoDB type tables:

how to make a search in text fields to match for keywords "keyword1 keyword2"
and
"keyword1" or "keyword2"
searching in text field ???

is there any way to know the raniking ?

MYSQL MATCH AGAINST Search, ASCII Characters, Etc.
Well, I am trying to make an internal site search for sometime now, and now I'm having this problem.

I have non english characters, like é, è, ç, à, etc. These characters are stored in the database in ascii format.

Now let's take a name Ségolène, this is stored in the database as Ségolène

Now to search that out, I need to make the word as "Ségolène" (double quoted).

Problem is, if I double quote, I get exact non english words, but I can't get nearby words, like I can't get Ségolène just by typing Ségo. As, to get Ségolène by typing Ségo, I need to make ségo* and this * and " " are not matching together.


FULL TEXT (match) Search Across Multiple Tables?
i'm trying to create a "search the site" field on my page. My site allows users to upload pictures and give them titles and descriptions. To search the whole site i'd need to search say the user database (name, short bio), and the image database (description, title) and return the results.

now, i've managed to do this by running the query once on each table and then sorting the total results by their relevence.

the problem i'm facing is in regards to pagination. If i set a limit for the results that limit would be applied to both queries and i would end up getting a different ammount of results per page depending on how many showed up in each query.

If i could run ONE query with the limit i imagine i'd be able to solve this. I hope that wasn't confusing. Also if anyone has an idea how to use the current multiple queries and paginate them accordingly i could use that as well. I've included a sample of the queries i'm using to search each table.

PHP

$sql="SELECT photos_gallery.image_id,(MATCH(photos_gallery.image_title) AGAINST('$search_string' IN BOOLEAN MODE)*100) + (MATCH(photos_gallery.image_desc) AGAINST('$search_string' IN BOOLEAN MODE)*10) AS rating FROM photos_gallery WHERE MATCH(image_title,image_desc) AGAINST('$search_string' IN BOOLEAN MODE) ORDER BY rating DESC LIMIT ".$page.",".$limit."";

$sql="SELECT `users_id`,(MATCH(users_name) AGAINST('$search_string' IN BOOLEAN MODE)*100) + (MATCH(users_bio) AGAINST('$search_string' IN BOOLEAN MODE)*10) AS rating FROM users WHERE MATCH(users_name,users_bio) AGAINST('$search_string' IN BOOLEAN MODE) ORDER BY rating DESC LIMIT ".$page.",".$limit."";


FULL TEXT (match) Search Across Multiple Tables
Hey, i'm trying to create a "search the site" field on my page. My site allows users to upload pictures and give them titles and descriptions. To search the whole site i'd need to search say the user database (name, short bio), and the image database (description, title) and return the results.

now, i've managed to do this by running the query once on each table and then sorting the total results by their relevence.

the problem i'm facing is in regards to pagination. If i set a limit for the results that limit would be applied to both queries and i would end up getting a different ammount of results per page depending on how many showed up in each query.

If i could run ONE query with the limit i imagine i'd be able to solve this. I hope that wasn't confusing. Also if anyone has an idea how to use the current multiple queries and paginate them accordingly i could use that as well. I've included a sample of the queries i'm using to search each table.


$sql="SELECT photos_gallery.image_id,(MATCH(photos_gallery.image_title) AGAINST('$search_string' IN BOOLEAN MODE)*100) + (MATCH(photos_gallery.image_desc) AGAINST('$search_string' IN BOOLEAN MODE)*10) AS rating FROM photos_gallery WHERE MATCH(image_title,image_desc) AGAINST('$search_string' IN BOOLEAN MODE) ORDER BY rating DESC LIMIT ".$page.",".$limit."";

$sql="SELECT `users_id`,(MATCH(users_name) AGAINST('$search_string' IN BOOLEAN MODE)*100) + (MATCH(users_bio) AGAINST('$search_string' IN BOOLEAN MODE)*10) AS rating FROM users WHERE MATCH(users_name,users_bio) AGAINST('$search_string' IN BOOLEAN MODE) ORDER BY rating DESC LIMIT ".$page.",".$limit."";

MATCH AGAINST Match Exact Word
I want to do the equivalent of

SELECT id from TABLE WHERE text='text'

only fast solution I found is:

SELECT id,text from TABLE WHERE MATCH(text) AGAINST('value' IN BOOLEAN
MODE) HAVING text='value'

Is there a better way to do that? Cause using having needs me to add a
column in select wich is a problem in some cases.

It has to return the EXACT WORD MATCH. so only rows containing the
exact "value" content in the text column will be returned.

Using Keys Properly
I have a couple questions on how to properly create keys. Basically i know nothing about them, how they work, how it speeds things up, and most importantly, where to create them to help speed up my tables.

I do have multiple tables that are used and joined together, i just dont know where to make keys. I heard that if you do it improperly, it can slow down your database too?

UPDATE Will Not Add Properly
I have an online comic engine I'm working on, and I just noticed that, as opposed to adding one view (like it should) it will always add two. Can anyone help me out with this? I've already determined it's just this line of code, and that it's not being called twice.

$query = "UPDATE `".SQL_COMICS."` SET comic_views = (comic_views + 1) WHERE comic_id = '".$comic_id."' LIMIT 1";
mysql_query($query) or die(mysql_die_message());
echo($query);

Properly Querying A Relational Db.
I've recently been working with more relational dbs and I was just wondering...am I working with them properly?

The reason I ask is because I'm wondering if there are easier/more efficient/more "proper" ways to be working with a relational db.

So here is an example: two tables, a project table and an employee table. The project table stores employee id in emp_id and is linked to the employee table by a foreign key (a one to one relation).

SELECT P.project_id, E.first_name, E.last_name, P.name, P.code, P.start_date, P.end_date, P.imdb
FROM project AS P, employee AS E
WHERE E.emp_id = P.supervisor
The thing is eventually we'll start to have tables with 4-5 foreign keys and I'm wondering if this is still "proper". Honestly it may seem a stupid question to some of you experts :-p

Getting Utf8 To Work Properly
I have made a few tables in a database, and I'm trying to get my Japanese text to display properly. I have the collation set to utf8_general_ci, and I even added the mysql_query("SET NAMES 'UTF8'"); code into the php page. But even with all of that in, it still won't display properly. The characters show up as ã‚»ã‚*ãƒã‚¯ã«ã‚“ã˜ã‚ƒãŸã„ã‘ã¤ï¼ and other junk like that.
Now this was working before until I added a second mySQL connection into the page, which inputs the second table. I'm not sure if you can make 2 connections on the same page, but I did and it pretty much messed everything up. I took the second table away, and things were still messed up.
My question is how can I get the Japanese text to display properly? It does display properly on the phpMyAdmin page, but I get garbage on the actual page.

How To Install Mydsl Properly
is there a step by step guide for installing mydsl properly and creating a databse?

Mysqld Is Not Running Properly
I have installed mysql server & client version 3.23.54a from Redhat installation 9.0. I could install the RPM 's with out any problem.

I can see 'mysqld' program . But when I run it shows a message like mysqld started [ok].When I checked 'ps aux' , I could not see any process running with mysqld. Also I could not run any programs like mysqladmin etc. All of them fail. does anybody know what is the mistake ? What should I do ? Also when I try to stop mysqld it fails.

Designing Databases Properly
After what seems like far too much agonizing, I think I've decided to build my own php "shopping cart" and hack my own interface to paypal IPN, because all the other solutions I've come across are massively oversized and overdeveloped for my needs.

But I could use some help in setting up the structure. I'm not sure of the best way to handle "options" with my various products.

First of course I set up a basic database with product fields like:
sku, price, name, etc. etc.

The tricky part is that some products will have special options, some dropdowns and some text fields, and I know I won't be able to predict all these in advance, like:
item color, accessory color, font, initial, initials ...

In addition, some products will call for extra product photos and others won't ...

And then I will need some way of storing all these extra options for a given customer's order when it comes through.

Extended-insert Not Working Properly
I am having a problem with using the --extended-insert option when using mysqldump. As I understand it, this option creates multiple insert statements within the .sql file for tables that contain more than 1 row of data.

According to documentation I have found, this substantially speeds up the restoration process. The main database I am concerned with uses the InnoDB engine, however I also want to backup the mysql database as well (which, to my knowledge, uses the MyISAM engine).

However, when I execute the database dump using this option, there is only 1 insert statement, and all values are seperated by commas. When trying to restore my databases, this causes my system to eventually freeze up due to the inefficiency of inserting multiple rows this way. I am using Windows XP, 1.8 Ghz, 512 MB of RAM.

The command I am issuing is as follows:

mysqldump --opt --single-transaction --u root --all-databases > "C: estbackup.sql"

I have also issued the following command, with the same result:

mysqldump --extended-insert --single-transaction --u root --all-databases > "C: estbackup.sql"

Properly Re-starting Replication Process
I've just tried to re-start a replication process and the slave's
tables came up marked as crashed. I'm doing a repair on one of them but
there are a lot of databases/tables so I can't check them all (or is
there a table entry somewhere that flags crashed tables?) Here is the
sequence I used: Code:

Storing Large Integers Properly
I am storing book isbn numbers in a table. isbn numbers are 10 digit
numbers and many start with 0. The data type of the field I am storing
this info in is a bigint(16) unsigned.

It appears that isbns that start
with 0 are going in as 9 digit numbers, the 0 is being ignored or
stripped. I have experienced this before with integer data types
ignoring leading 0s. I'm wondering how to address this? Should I
change the field to a varchar or char data type?

Two Digit Numbers Not Formatting Properly
I have a table I am using to populate drop-down menus. It is for languages.
each language has a specific code that must be saved to the field in question.They work fine except for two codes: 00 and 01.
I can't change the codes to anything else. They have to be 00 and 01. THey are saving to the spreadsheet as 0 and 1 however.

Inserting Dates Properly Formatted
I have a dataset that has all it's date formatted as MM/DD/YYYY. I want to be able to insert this into a table that is using a field set as 'date'.
How would I go about properly formatting the MM/DD/YYYY to insert into the table?
Right now when I insert I end up with all the dates storing wrong. IE: 9/6/2005 stores as 2009-06-20.

Mysqlcheck: Clients Are Using Or Haven't Closed The Table Properly
I'm using the command mysqlcheck --all-databases --auto-repair --silent
and I see these warnings (listed below) on a daily occurrence. Is mysqlcheck
causing these warnings? I can't see how a table can close inappropriately.
How can I prevent this.

Hoping to here from MySQL users who have came across this. I'm using MySQL
4.1.11 on RHEL. Code:

Getting Text Retrieved From Mysql To Fit Tables Properly
I have been working on a really simple mysql/php set of pages.

Page 1: Input 3 peices of data (Title, Date and Text)

Page 2: Display all news that has been inputted

I have it working, except for one problem. My website is built with html, and tables. I want it so that when the text gets to the edge of the table, it drops down a line and starts again on the next line - so it doesn't carry on and on.

Theres no problem with title and date - they're just a few words, but the text part of the news is usually 5 or 6 lines long. This means that it wont all fit on one line without ruining the entire website display. Code:

Don't Select Rows That Match Both Columns But DO Select Rows That Don't Match Both
I suppose it is because it is 2:30 AM but I'm having a bit of trouble figuring out the SQL I need to write. I am usually pretty good at this. Here's what I'm having trouble with.

My app includes a Poll system built from scratch. Each question will run for one month. the month that the poll will run is kept in 2 columns in my table... runMonth and runYear.

What i'm having trouble doing is selecting the rows that don't match both the current runMonth and current runYear.

My Table...

id.............Question...........runMonth...........runYear
1..............QA...................1......................2007
2..............QB...................2......................2007
3..............QC...................3......................2007
4..............QD...................4......................2007 (current month and year)
5..............QE...................5......................2007
6..............QF...................6......................2007

I can simply get the question for the current month...



SELECT * FROM table WHERE runMonth = 4 AND runYear = 2007;
but if I try to get all others using


SELECT * FROM table WHERE runMonth != 4 AND runYear != 2007
I get an empty result set. As I should because there is nothing there that the runYear != 2007 doesn't knock out. The result set I am looking for is


id.............Question...........runMonth...........runYear
1..............QA...................1......................2007
2..............QB...................2......................2007
3..............QC...................3......................2007
*********************(remove runMonth4 and runYear 2007)
5..............QE...................5......................2007
6..............QF...................6......................2007

What am I missing?

How To ORDER BY DESC Properly. It Makes 150 Before 50 If ASC Order!?
I have this list:
50
150
200
250
300
350
400
450
500

If I order it by ASC order then mysql results this:
150
200
250
300
350
400
450
50
500

What the hell ?? How do I order it properly?

Search: Remove Quotes From Database For Search
I am making a book site and currently in the database are book titles likes "John's Trip" and "Peter's new bike". I have a search function where the customer can type in "Peter's" and it will bring up everything with "Peter's" in it.

But i was wonderind is there any way i can search for "Peters" and "Johns".

MATCH AGAINST
I am trying to return results with the MATCH AGAINST queries but for some reason the results are inconsistent, i have the FULLTEXT index for the appropriate field but it seems sketchy. I've instead been using a regular expression in my query for time being, but as you can imagine this is getting highly impractical as the database grows and grows every minute.

Here is an example:

Best Match
Hi, here's the question:

I have a table wich contains productinformation with a field called PRODID. Then I have another table wich is contains groupinformation. This contains a field called GROUPID, wich is the beginning of the PRODID's. A product belongs to the group with the longest matching GROUPID. For example:

+-----------+--------------+
| GROUPID | DESCRIPTION |
+-----------+--------------+
| 015543 | hats |
| 0155 | boots |
+-----------+--------------+

+-----------+--------------+
| PRODID | DESCRIPTION |
+-----------+--------------+
| 01554300 | Yellow hats |
| 0155000 | Yellow boots |
+-----------+--------------+



Say I have the value of PRODID (e.g. "01554300") and I want to select the group tou wich it belongs. In the example the returned group would be "hats" because the match "015543" is longer than the match "0155".

I also need it the other way around: I have the value of GROUPID (e.g. "0155") and I want all product wich belong to this group... It should return "Yellow boots" but not "yellow hats" because there's a group with a longer GROUPID that matches the beginning of the PRODID.

Match() Against()
query
====
select * from Products where
match(Description) against('and');

table
====
CREATE TABLE Products (
ProductNameVARCHAR(50)NOT NULL,
DescriptionTEXTNOT NULL,
FULLTEXT(Description)
) ;

INSERT INTO Products(ProductName,Description)
VALUES ('Aan', 'The movie promises to be true to life and aims at showing the Police department in India, in a constructive fashion.');

MATCH
This is my query for a search

SELECT *, MATCH (title,short_desc,text) AGAINST ('$search') from
announcements WHERE MATCH
(title,short_desc,text) against ('$search');

where $search is from a form search box thing, results sorted by relevence.
Now it all seems to be working fine except, when testing it I have found that 'fireworks' returns a result, but 'fire' or even 'firework', does not. What can I do to make it if it is at the start of a word, to return this result?

Match Against
Alright, someone please explain to me why this:Code:

SELECT * FROM products WHERE MATCH(cat3) AGAINST('Apple' IN BOOLEAN MODE)

works, and this:Code:

SELECT * FROM products WHERE MATCH(cat3) AGAINST('Other' IN BOOLEAN MODE)

doesn't?I have 2 products, one has 'Apple' in cat3, and the other has 'Other' in cat3. There is absolutely NO difference other than that

Match Against
I work with fulltext index research... match against in boolean mode....
so, my sql query works, i have results, but the pertinence is the same for all results.... which is very stange and not normal...
my request is:

SELECT *,MATCH (Id, Titre, LegendeImage, Generique, Forme, Genre,Resume, Locuteurs, Personnes, Lieux, Themes, ContexteHistorique, ContexteMedia, ProducteurDiffuseur, Corpus, Transcription)
AGAINST ('europe >france' IN BOOLEAN MODE) AS Pertinence
FROM documents
WHERE MATCH (Id, Titre, LegendeImage, Generique, Forme, Genre,Resume, Locuteurs, Personnes, Lieux, Themes, ContexteHistorique, ContexteMedia, ProducteurDiffuseur, Corpus, Transcription) AGAINST ('europe >france' IN BOOLEAN MODE)
GROUP BY Id
ORDER BY Pertinence DESC

so, I got results, but no way to have a coherent pretinence... any idea?

MATCH () AGAINST ()
I have MATCH () AGAINST () working on one server, but it's not working on hosted server (dreamhost). For instance, something as simple as this works well on one but not on the hosted server:

SELECT ID, topic FROM feiaa_discussion WHERE MATCH (topic) AGAINST ('welcome')

Any reason why this could be? The versions are almost identical and there's no difference between versions anyway. Do hosts sometimes disable this function?

Records That Don't Match
I have two tables. One has bar information. The second has the bar's drinks. They are tied by 'bar_id'. So there are either one or multiple records in table 'bar_drinks' for a given bar_id.

The problem is finding the bars that don't exist in the bar_drinks table. I tried several ways, even a subselect, but get an error of more than one row existing:


SELECT bar_name FROM bar WHERE bar_id = (select distinct bar_id from bar_drinks)

I see the error here, but really am stumped how to achieve this....

2 Of 5 Conditions Match
I need my query to match at least 2 of 5 given conditions.

Example:
I have conditions
content REGEXP 'A'
content REGEXP 'B'
content REGEXP 'C'
content REGEXP 'D'
content REGEXP 'E'

I need database to return this entry only if at least 2 conditons are true.

MATCH Statement
Can anyone tell me why I get a blank result from the following statement please?....

What Is The Diff. B/w Match And Like
I try to write this query

SELECT SQL_CALC_FOUND_ROWS Ch.id as id, Ch.name_arabic as ChName, Ch.logo as pic , Lang.name_arabic as Lang , Class.name_arabic as Class, Grp.grpname_arabic as 'Group', Owner.ownername_arabic as Owner FROM channels AS Ch , classifications AS Class , languages AS Lang , ownership AS Owner , groups AS Grp WHERE (Lang.id = Ch.language_id) AND (Class.id = Ch.classification_id) AND (Owner.id = Ch.ownership_id) AND (Grp.id = Ch.group_id) AND (MATCH (Ch.name_arabic) AGAINST ('%2M%')) ORDER BY Ch.id LIMIT 0,5
it's not working , but when write it using like

SELECT SQL_CALC_FOUND_ROWS Ch.id as id, Ch.name_arabic as ChName, Ch.logo as pic , Lang.name_arabic as Lang , Class.name_arabic as Class, Grp.grpname_arabic as 'Group', Owner.ownername_arabic as Owner FROM channels AS Ch , classifications AS Class , languages AS Lang , ownership AS Owner , groups AS Grp WHERE (Lang.id = Ch.language_id) AND (Class.id = Ch.classification_id) AND (Owner.id = Ch.ownership_id) AND (Grp.id = Ch.group_id) AND (Ch.name_arabic like '%2M%') ORDER BY Ch.id LIMIT 0,5
every thing goes ok , and there is data,
I don't know the reson, where my table collection is "cp1256_general_ci"

Mysql MATCH AGAINST
I have a table full of city name and an auto-complete field hat output result in a php search page.

So when I type 'Mon' it output me this:

- Montreal, QC
- Montreal-Est, QC
- Montreal-Ouest, QC

then, if I type 'Mont', it does not output me Montreal, QC but only the 2 others?

So is someone can explain me why?

Match Against Issues
I have a query that is searching a fulltext field in the database using match against. I get 0 returns, however i believe this might be caused by the keyword being in to many rows and is being ignored by default in mysql. I've posted the query in case i am wrong. However if i'm not wrong how would i create a fulltext search? ....

Match And Join
I have a search function that works fine using the Match command.

SELECT *,
MATCH(supplierCatNo, name, description)
AGAINST ('".$searchstring."' IN BOOLEAN MODE)
AS score FROM ".TABLE_PREPEND."_products
WHERE MATCH(supplierCatNo, name, description)
AGAINST ('".$searchstring."*' IN BOOLEAN MODE)
ORDER BY score DESC";

Now I want to include a JOIN command to use the supplierCatNo to lookup the SupplierName (in _suppliers table) when searching.

Is this possible? What would the syntax be? I've spent a fully day now trying to get this to work and I feel like throwing my keyboard out of the window.

FULLTEXT MATCH()
I am refining the search within a small IT Jobs Website developed in
C#. I am using FULLTEXT search on 3 columns (title, short_desc,
long_desc), but am having trouble becuase some queries for the database
will be "c#" and "asp.net". The Match() function does not recognise
these types of keywords because the length is less that 4 characters
and a "." in words splits it into 2 words each 3 charaters long.

Anyone find a way around this? I like the Match() function as it brings
more relevant result back first in most cases.

Closest Match
Is it possible in SQL to find a 'closest match' with a set of numbers? eg
I have a db with fields R, G & B

then I have values r, g & b and I want to find the record that is closest in value to r,g&b.

MySQL MATCH PB
We use the MySQL MATCH function to search a product catalogue (which has a fulltext index on 3 columns). An example query looks like this:

SELECT p.Name, etc FROM Products AS p WHERE MATCH(p.Name, p.Description, p.Keywords) AGAINST ("q 10") GROUP BY p.ID ORDER BY MATCH(p.Name, p.Description, p.Keywords) AGAINST ("q 10") DESC

The problem is that many of these products have words or phrases that are 1 or 2 characters long (eg "Q 10").

We want to avoid changing the min. word length so we don't impact on performance or other databases. Am I right in thinking that the only way round it is to revert to using LIKE(%Q 10%) , or is there some way of altering the MATCH fuction to find what we need ( or mabye using MATCH in the first place and reverting to LIKE if no results are returned - can this be done in one query?)

JOIN MATCH AGAINST
I have two mysql tables - pictures and pictures_categories. I want to search the pictures table with $searchstring, and the pictures_categories with $searchcategory.

I think I may have made a sloppy effort at joining these tables... My code:

$sql = "SELECT pictures.*, pictures_categories.* ".
"FROM pictures, pictures_categories".
"MATCH(pictures_categories.picture_id, pictures.keywords)
AGAINST ('$searchcategory $searchstring' IN BOOLEAN MODE) AS total_entries FROM pictures, pictures_categories
WHERE MATCH(pictures_categories.picture_id, pictures.keywords)
AGAINST ('$searchcategory $searchstring' IN BOOLEAN MODE) ORDER BY pictures.id DESC LIMIT $offset , $total_entries";

e.g.
pictures
id | keywords | image
1 | Castle, Mountain | image1.jpg
2 | Tree, Park, Castle | image2.jpg
3 | Car, Man | image3.jpg

pictures_categories
pictures_id | category_id
2 | 223

So, for example, if i searched for castle with a category id of 223 I would only get the result image2.jpg (id = 2) dispite castle being in image1 aswell.

Collations Mix Match
I've setup my own deadicated server and everythings well apart from mySQL.If defaults every database and table to latin1_swedish_ci
I have no idea if it needs to use this collation but its giving some php apps a problem.
I'm running 4.1.9 nt with php 5 on 2K3.
I think I'm going to have to manually ajust the collation on all my existing databases, but how do I stop this happening?

Match Keywords
I have keywords with logical operators "and(+), or(|), and not(-)", and I want to match them with a row in database with similar keywords.

For examples:

a. (good+(morning|night)) -afternoon
b. good+night -morning <---- this is stored in row in the table in DB

It's easy to send a query to match these 2 without taking account of the "NOT morning" in (b). But if you take account of that, these 2 won't match. The only way I thought of so far is to send a query and match (b), then do a 2nd check with the negative keyword to determine that they don't match. But it is not efficient if there are a lot of positive keywords or many rows like (b).

MySQL Match
Could someone give me just a bit of assistance here? I am running into a brainlock and cannot see what the problem is...I'm sure its obvious. Here's the code:

 $sql = mysql_query("SELECT * MATCH(title) AGAINST ('$title') AS score FROM articles WHERE MATCH (title) AGAINST ('$title')") or die(mysql_error()); 

I am getting an error on this statement. What is it that I am doing wrong?


Copyright © 2005-08 www.BigResource.com, All rights reserved