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




Search With Multiple Fields


I have a form with essentially 5 different selects, let's call them country, state, subject area, tag, and age range. What I want to do is find all of the users who are the closest match to the search query (once I know how to do this, I can modify the query to find their names, email addresses etc...)

In the database, users have a country_id (not name!), state_id in one table, and subject area id, tag id, and age range id in another table (all in the same column as multiple rows for the same user).

I want to do a database search and match all of the users who meet at least 1 of the criteria, and sort them in order of closest match (all 5 criterion) to least match. Assuming I consider the order of preference to be subject area, tag, age range, country, and then state, how do I do this?

To make the problem even slightly more difficult, the form doesn't return the actual country name, it returns the row the country shows up in the country table (same for the other fields) so I'm currently doing a look up for each field to figure out which country/state/etc... I'm actually dealing with.

I don't see how I can do a FULLTEXT search for this information because it is all in different columns.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiple Search Fields And Subqueries?
I'm trying to construct a query in PHP that will be able to handle multiple search fields. The data is in multiple tables.

COMPANY
company_id
name
address

SERVICE TYPE
company_id
service

OFFICE LOCATIONS
company_id
city_name

My question is how do I construct a query that will allow there to be these three search fields (company name, service type, location).

I know that subqueries are probably needed, but I'm a newbie and still not quite clear how to get these to work properly.

The queries I've been able to construct return zero results unless all fields are filled in, or they return multiple listings of the company name since the company may have more than one office location. I don't want the user to be required to fill in all fields to get meaningful results.

Query To Search Multiple Fields
I have a table with over 50 columns that contain yes/no values. I want to know if there is a way to write a query to get all fields that have a value of "no".

Search Fields
I am using a script template to search one specific field from a table in my SQL database.

I am using the following code and when I put in a search word which I know exists in the field of the table, the response i get is:

"Please enter a search..."

Here is the code (without the obvius HTML form information):

How To Search All Fields For An Item?
I currently use a query like:

SELECT * FROM sr_main WHERE footprint LIKE 'conn%0p80%';

What I would like to be able to do is search ALL record fields rather than searching just the field 'footprint'.

There must be an easy way!?

I thought this would work:

SELECT * FROM sr_main WHERE * LIKE 'conn%0p80%';

but it seems I can't wildcard the fields... is that right?

Search All Fields For String
I have an email address entered wrong in some mystery field in the db, but have no idea where it is to correct. The only way I know about it is it comes back with bounced emails. Not sure if it is stuck in my CRM's cache, or in the db. Is there a way I can search all tables, all fields for the specific string???

Conditional Search Fields
i'm having the user input certain search fields from a typical html form .. passing them in with $_POST (<--php stuff) values .. and then i'm stuck at writing my query ...

what i have now is..
    $query = "SELECT * FROM networks WHERE name='$name'
                                     and latitude='$latitude'
                                     and longitude='$longitude'
                                     and elevation='$elevation'";

when i input the name to search for it doesn't return any answers becasue the other fields are null from the input field .
thanks much in advance :) If programming were as fun as cycling, then we'd need more bike mechanics.

Full Text Search On Combined Fields Values
first_name, last_name, introduction
bill, gates, bill has a lot of bills

if i do a full text search of "bill gates" on the fields "first_name, last_name, introduction", it will not return the above record. Even the first_name and last_name combine will have a word "bill gates".

Is there a way, that I can make the full text search return the above record?

Passing Search Data To D/b Via A Hyperlink And Without Input Fields
How can I pass hard-coded search data to a MySQL results.php page with a hyperlink and without input fields?

These are the details:

I have a simple online database which can be searched by classification (business type) and/or company name (it does an 'or' search).

There is an index.php (search) page and a results.php page. (The results page also has a search, which leads back to the same results page.)

What my client wants to do is this:

If some records are returned, it gives a list on the results page of companies found to match the criteria (this works just fine).

But if no records are found, he wants a list of classifications, each of which is clickable, and will do a search for all companies with that classification.

It doesn't matter whether this would be on the same results.php page or another page.

Multiple Fields
i have a query regarding mysql like clause.can we use
select name like 'john%' or 'bill%' from nametable ;
Is the above syntax correct or is it wrong.If wrong please give me the correct syntax.
what i am trying to do is that i am trying to select either john or bill with sum last name in all the rows.

Update Multiple Fields
I need to update some 900,000 records, each different. I will be pasting the code into the sql window of PHPMyAdmin at my web site. The individual updates look like this:

UPDATE table SET Field1='sample', Field2='sample1' WHERE UniqueID=12345

UPDATE table SET Field1='sample2', Field2='sample3', Field3='yes' WHERE UniqueID=2021432

How can I string together a bunch of these where the SET field values are always different and there is one each for 900,000 different ID's. Right now, I have these in 30 text files but I can't seem to get the syntax correct.

Count Of Multiple Fields
I have a database that stores some stats for a hockey league in the following manner:

Field names are GP, G, A

Whenever a player Plays a game, his ID is added to the column GP while other columns go to 0
If a player scores a goal, his ID goes under G, the guy who assisted goes under A

What I want is a query that can give me the count for each ID that shows up in GP for GP, G and A

Is there an easy way to do this with just one statement? Right now, it's really messy since I have to loop through each player ID in GP and make individual queries to count GP, G and A because I can't figure out an easier way and I don't want to rebuild the DB

Update Multiple Fields With 'OR'
Is there a better way to do this (more efficient).

I have up to 200 items to update per query, the id's are not sequential. Using up 200 (well 199) OR's in a single query doesnt strike me as being the best way to do this. All the fields get set to the same value.

# Example
UPDATE table SET value=value WHERE id=11 or id=23 or id=31 or id=74 or id=56 or id=96;
# Up to 200 fields

Or am I stuck with this query? (which works).

Multiple Distinct Fields
Okay SQL gurus, I have a table laid out as so:
RowID | UserID | UserType | pID

Now, how can I write a SQL query that would select every distinct UserID and pID combination.

So if the data in the table were:

1 jjdoe internal 19
2 jjdoe internal 6
3 jjdoe internal 6

It would only return rows 1 and 2.

Ordering Multiple Fields
I'm relatively new to mySQL so I've been looking around the internet for help on how to order based on a user-defined pattern and haven't seen exactly what I'm looking for. If someone could help with this example I created to illustrate what I'm trying to do in general, I'd greatly appreciate it.Let's say I have a table in my database of Army officers with the following fields: rank, lastName, firstName.

I'm looking for the right query so I can display in an HTML table every officer in the mySQL table and order the rows first by rank, then by lastName (if ranks are the same), then by firstName (if ranks and last names are the same).

Displaying Multiple Fields
I am sure amongst this community that this question is rather straight forward.
I have a database where a table is added that contains the user login, password and other user information.
What I wish to do now is for each user I want to be able to add a product description, old price and new price.
So when this particular user logs in, they will see a list of products on one column and then the old price in another column and new price in the third column.
The prices obviously have to be matched to the same product.
Eg:
productA new_price1 old_price2
productB new_priceX old_priceY

How would one do this?

Comparing Multiple ID Fields
I have an advert table which contains three category ID fields (catid, catid2, catid3). These catid fields match up with the catid field in the category table. I want to run a query that returns any row that contains any mention of a specific category.

SELECT * FROM advert, category
WHERE advert.catid = category.catid
AND advert.catid = '3'

The above query works fine for the first advert.catid field, but once I introduce...:

OR advert.catid2 = '3'

... the results start getting strange. The same row is returned 9 times.

GROUP BY Multiple Fields
Can somebody show me how to properly use GROUP BY if I'm using multiple fields.
For instance:

I have a table that has a month field and a year field. I want to group all entries by month and year. How do I prevent grouping a record from January 2007 with a record from January 2008?

Indexes With Multiple Fields
I have seen some tables that have indexes which contain multiple table fields. What is the purpose of having an index with multiple fields instead of a seperate index for each?

Duplicates On Multiple Fields
The table has fields:
home_id, owner, street_number, direction_one, street, street_type, city

I have a problem where the same address information was entered in but with different owners. How do I find all the duplicates? I tried this query:
SELECT home_id, street_number, street, city
FROM home_data
GROUP BY street
HAVING ( COUNT(street) > 1 )

but that only works for duplicates on street, at the very least it should check for dups on street_number and street and city. When I ran the above query it took forever. My table has over a million records in it. Basically my computer froze up but kept running and I kept getting virtual memory errors.

Multiple Search
before i start building my database with multiple tables i just want to clarify i can do this

i'll have 1 db with around 10 tables

the layout and structure of each are all the same but i wanted to separate them so dont end up with one huge db

i'm assuming i can do this:

$query = "SELECT lat, lng, html, label, icontype, advert, display FROM 'table1', 'table2', 'table3' WHERE icontype='" . $_GET['name'] . "' OR keyword='" . $_GET['name'] . "' OR town='" . $_GET['name'] . "'";

How To Update All Fields With A Multiple Of The Field Value?
Is there a MySQL command to replace all the values of a field with the field's original value that's had a mathematical formula applied to it? Basically, I want to divide the field's original value in half, then add 40% more. The formula would be y=x/2+.2x where y is the new value and x is the original value.

I know I could write a PHP script that would select each field's value, apply the formula, then update the new value, but it'd be cool if there's a MySQL built-in function to do this.

SELECT DISTINCT With Multiple Fields
I'm kind of stumped on a query I'm trying to build. basically I have a forum table like this:

Post_ID | Thread_ID | Post_EntryDate | etc.....
90 | 22 | ....
89 | 21 | ....
...
...
...
85 | 1 | ....
84 | 1 | ....
83 | 10 |....

and so on. I would like to get the last 20 threads with most recent posts filtering for Thread_ID duplicates of course. so far I have this:

SQLtemp = "SELECT DISTINCT Thread_ID FROM Posts ORDER BY Post_ID DESC LIMIT 0,20"

this succesfully returs a list of unique Thread_IDs of the last 20 threads with most recent posts. However, I need to get the Post_IDs and other fields but when I throw Post_ID in the SELECT statement all I get is duplicate values for Thread_ID

How Change Multiple Mysql Fields?
I have a table with 2,733 records.

I need to change a field (published) on all records to show ....

Count Fields Over Multiple Rows
I have a database like this

id, field1,field2,field3,field4,field5

Database contains 100 rows, some rows have no fields filled, some
1field , some 2 fields etc.

How would i count the number of fields filled in total?

So the outcome is (number of fields filled in row1)+(number of fields
filled in row2)+(number of fields filled in
row3)....................+(number of fields filled in row100)

Sort By Multiple Fields In Different Directions?
I'm wondering if I can sort by multiple categories in different directions. I tried this and it doesn't work:

SELECT * FROM table ORDER BY field1 DESC ORDER BY field2 ASC LIMIT 0,10

JOINing From Multiple Fields To One Table
I have two tables in a MySQL database. One has the publication data (title, ISBN etc), and the other has the data on the authors that wrote it (first name, second name, etc.)

I am trying to produce a single recordset that will show the authors' names (first name + a space + second name). The staff.staffID corresponds to publications.author1, publications.author2, etc.

The problem I have is that there are potentially 5 authors for each publication record, so when I try to LEFT JOIN them all them to the staff table, I get a '1066 not unique table / alias: staff' error - I can see why this is happening (becuase of the 5 left joins onto the same table) but how should I change the code to get the results that I need? Code:

Multiple Fields Linking To One Foreign Key
I have a table that is going to track project info, time, date, people working on the project, materials, etc.

My question is what would be the best way to have multiple fields for the people working on the project, for example this is my current layout (don't laugh too hard):

tbl_washLog (washID*, time, date, crewID**, crewID2**, crewID3**, tailID, paintID)

The crew ID fields need to be foreign keys back to the crewID field in the crew table which is:

tbl_crew (crewID*, firstName, lastName)

(* = Primary Key, ** = Foreign Key)

Is it possible to have crewID, crewID2 and crewID3 all be foreign keys of tbl_crew.crewID? If not, what would be the best way to go about doing this?

Select Fields Accros Multiple Dbs
I am trying to use the SELECT DISTINCT statement to create one list of email address I have which are in two different databases, I have tried the below syntax, but does not seem to work...can anyone please tell me where I am going wrong!

SELECT DISTINCT m2e_db.email, events_bookings.email FROM m2e_db, events_bookings ----Ment2Excel (M2E)----
  --LEARN BY EXAMPLE--

How To Search In Multiple Tables
i want to search in multiple tables with selected fields in each table, i make a query like this:

SELECT location_id FROM locations_mast WHERE description like '%$Keyword%'
union
SELECT course_id FROM courses_mast WHERE description like '%$Keyword%'

its giving me results but as the "union" use the first SELECT statement as the column names for the results, its giving me only one record set as "location_id"

i want all the separate column names in the record set as location_id, course_id so on...




Search Multiple Columns
I would like to search for a keyword '%schultze%', and I would like the search to include more than one column. I was experimenting with this:

SELECT * FROM `listItem` WHERE `owner` = 128 AND MATCH (`title`) AGAINST ('%schultze%');

But I would get funny errors complaining about not being able to find a FULLTEXT index. I imagine this is something that has to be built before the search happens. As the database is changing all the time, I would want this to be built once a day. Perhaps I could stick a batch file in the xinetd that would take care of that.

Ideally I would like to search over 10 columns, (with the constraint that the owner equals 128) that are varchar and text, all utf8_general_ci. I suppose this would look something like:

SELECT * FROM `listItem` WHERE `owner` = 128 AND MATCH (`referenceNumber`, `title`, `menus`, `added`, `format`, `ratio`, `source`, `description`, `genre`, `rating`) AGAINST ('%schultze%');

Or perhaps I'm barking up the wrong tree here and I could do a search that was like this:

SELECT * FROM `listItem` WHERE `owner` = 128 AND (`referenceNumber`, `title`, `menus`, `added`, `format`, `ratio`, `source`, `description`, `genre`, `rating`) LIKE ('%schultze%');

But where mysql would know each column was OR, where '%schultze%' matches for `referenceNumber`OR `title` and so on,

Search Through Multiple Tables
I currently have an Access DB I migrated into MySQL. The DB conists of multiple tables representing the same data but differentiated by month

Ie.
table 2003 07 consists of field 1,2,3, etc
table 2003 08 consists of field 1,2,3, etc
where the field properties don't change

Is it possible to run a query through all tables at once (ie. to find where field 3 = xyz)

If not, what would be the best course of action

all the DB i'm looking to migrate are in this format.

Multiple Table Search
Firstly I am using ASP pages and a MySQL database with 8 tables in it.

These 8 tables contain userdata each table holds different data about the user.

What I need to produce is a search engine that will perform a search on all tables, displaying the results, with a description of what it has found (stored within the table where the search item was found).

There are only certian fields that can be searched on within each table. I am having great troubles with this as if the user has multiple entries in any table I get that amount of results plus the result of the item itself.

Multiple Table Search
I am using the follow statement to search a single table in a db.

SELECT Dock, Name, Address, City, `State`, Postalcode, Mainphone
FROM beatxtankerterm
WHERE Name LIKE %colname%
ORDER BY Dock ASC

I would like to be able to search multiple tables. I have tried many combinations but have not found the right one.

Multiple Table Search
I am running a search on multiple tables for a match using:

... MATCH(table1.full_text_index) AGAINST ('string') OR MATCH (table2.full_text_index) AGAINST ('string') OR....

I want to be able to tell which table find a match. If there are multiple tables that find a match to able to identify which table found a match.

Extract Date Into Multiple Form Fields
I'm storing standard datetime values in a MySQL table (i.e. 1999-12-31 23:59:59). A query such as:

"SELECT thedate FROM tablename"

returns the expected 1999-12-31 23:59:59

How can I extract the indivdual elements into separate PHP variables like:

theyear = 1999
themonth = 12
theday = 31
thehour = 23
theminute = 59
thesecond = 59

I've searched through the forums and thought DATE_FORMAT would be the ticket, but so far haven't been able to find anything that addresses this particular issue.

Updating Multiple Rows With Same Fields (in One Query?)
I have 2 tables here

table categories

+--------------------------------------- +
| cat_id | cat_name | cat_total_articles |
+----------------------------------------+
| 1 | PHP | 23 |
+----------------------------------------+
| 2 | MySQL | 17 |
+----------------------------------------+
table articles

+---------------------------- +
| article_id | article_cat_id |
+-----------------------------+
| 1 | 1 |
+-----------------------------+
| 2 | 2 |
+-----------------------------+
Now I've changed an article's category from cat1 to cat2, and I need to update cat_total_articles of both cat1 (minus 1) and cat2 (plus 1) in category table.

Is it possible to combine the following queries into one statement?

PHP

mysql_query("UPDATE categories
SET cat_total_articles = cat_total_articles + 1
WHERE cat_id = 2");

PHP

mysql_query("UPDATE categories
SET cat_total_articles = cat_total_articles - 1
WHERE cat_id = 1");

Is It Possible To Sum The Values Of Multiple Fields On A Single SQL Record?
I have fields for Goals and Assists.

I want to take those 2 fields and sum them to make a 3rd field PTS, then send them to variable in my PHP code to be printed to the screen.

My statement is this:

SELECT player_stats.G, player_stats.A, SUM (player_stats.G + player_stats.A) PTS
FROM player_stats
WHERE player_stats.PID =10
AND player_stats.season =1

The statement breaks with the bolded part.

Joining Multiple Fields To A Single Table?
I have 1 table with 2 columns, 'id' and 'name':

tbl_names:
idname
------
1Bob
2Jeff
3Fred
4Joe
5Bill


I then have another table which contains several fields which hold id's
from the above table:

tbl_output:
idperson1person2person3
-----------------------
1231
2543


I need a query that will return the names for the specified id from
tbl_output.
If I have just one 'person' field in tbl_output I would do it with an
inner join like this:

SELECT name from tbl_names
INNER JOIN tbl_names on tbl_names.id = tbl_output.person
WHERE tbl_output.id = ?

but I can't figure it out when theres multiple fields to be joined from
the same table...e.g I want to specify tbl_output.id = 1, and it give me:

person1person2person3
---------------------
JeffFredBob

Search Results In Multiple Columns
Currently using

WHERE email LIKE '%$keyword%'
I would like for the keyword to look into multiple fields


WHERE email,fname,lname LIKE '%$keyword%'
Searching the entire table would be fine too.

I tried something similar to the above and it didn't work. Sorry if this has been covered before. I couldn't find a thread...

Search Multiple Tables With Relevance
I am curious how relevance searching works. I have about 11 tables and I would like to make certain fields in those tables searchable, and the results displayed by relevance.

I've thought about this many different ways to do this, but haven't come up with a way that seems the simplest as well as provides the best performance.

See, I would like each of my search results to display differently based on what table they are coming out of. For example, if a user searches for "Accounting", I would like to hit the "departments" table and find accounting, then display the phone/fax numbers to that department, then move onto the employees table and find the employees that are in the accounting department, showing their name, extension, and title, and then finally go into our table of documents and display any documents with "accounting" in the designated text search field.

What I'm asking for may be too complicated, however I feel this is going to provide the best results for our users when they use the search box.

If all this sounds like too much to try to accomplish, then how could I just do a search through each of my tables and return the results by % of relevance?

Search Multiple Tables With Same Data
I have 3 tables where Product col is the same across all 3.

Tables
id /Product / Price

So far I have been using
$query = "Select `product`, `price` as p, 'tbl1' as n from `tbl1` where `product` REGEXP '".$trimmed."'
UNION ALL
Select `product`, `price` as p, 'tbl2' as n from `tbl2` where `product` REGEXP '".$trimmed."'
UNION ALL
Select `product`, `price` as p, 'tbl3' as n from `tbl3` where `product` REGEXP '".$trimmed."' ORDER by `name`";

Output gives me
Product | vendor | Price

Wanting to do a search where product is combine from all 3 tables and prices in different colums - >output

Product | Price (tbl1) | Price (tbl2) | Price (tbl3)

Any idea's ?

Fulltext Search: Multiple Tables
Let's say I have two tables: TblCategory (with CatID and CatName) and TblProduct (with ProID and ProName). I want to od the equivalent of MySQL's fulltext search, but I want it to match CatName or ProName. I know the MySQL's fulltext search is only for single tables.

Sorting By Same-data Fields From Multiple Tables *without* UNION
Is there anyway I can sort by two columns (which are the same datatype) from separate tables (whether selected via Table1, Table2... or by LEFT JOIN) without using UNION?

Search Multiple Columns And Return One Set Of Results
I have a table that has three fields that I want to be able to search (county, town, village). The problem being that I then want to be able to return a single set of results in Alpha order.

For example, if I write three queries that each search one of the three fields for LIKE 'P%' to give me all records that start with the letter P, I then need to sort the combined results into a single list in ascending order.

I can write three queries but end up with the data in different fields (obviously) and can not find a way to merge the field values into a single column.  Merging the 3 fields for each value will not give me what I want, I need to just see the value for the field that satisfies the select condition.

Selecting Language Depended Fields Through Multiple Table References
For a long time i think i need your instructions dear people on sitepoint. I'm making a sql query for getting user info, but i dont know how to handle this situation:

SELECT
user.name, user.firstname, user.lastname, ___ as user.city, ___ as user.province
FROM
user, languagefield, city, province
WHERE
user.id = %i
AND languagefield.language = %i
AND city.id = user.city
#tricky part
AND city.name = languagefield.id
AND city.province = province.id
AND province.name = languagefield.id
So i'm trying to get users first and last names plus city and province names from language tables. Is it possible with one query? How would you make SELECT and WHERE clauses?

Im using this db tbl scheme:

table : city
id (int4) primary key
name (int6) ref languagefield.id
province (int4) ref province.id

table : province
id (int4) primary key
name (int6) ref languagefield.id

table : user
id (int4) primary key
firstname (varchar32)
lastname (varchar32)
city (int4) ref city.id

table : language
id (int3) primary key
char2name (varchar2)
name (int6) ref languagefield.id

table : languagefield
id (int6)
language (int3) ref language.id
value (varchar255)

id + language unique

*****

I'm also thinking and planning to set more current language depended content to my application, so this is very important part of my design, 'cause it could be reused when dealing with other tables and fields.

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."";

Fields In One Table Overwrite Fields In Another Via JOIN
I'm writing a simple web game which uses mysql to store data. The prototype works ok so far, but now I'm refactoring it to support multiple players. This means coming up with a way to store the player's current world state.

I'm thinking of doing this by having a table that defines the initial world state, and then a table containing the 'state' of anything different.

Example:
The 'objects' table looks like this:
object_id, name, room
1, Hammer, 1
2, Mirror, 1
3, Spade, 2

So, at the start, room 1 contains a hammer and a mirror, and room 2 contains a spade.
Now, if player 12 picks up the hammer then drops it in room 2, I store this override in the 'state' table

player_id, object_id, room
12, 1, 2

So. I'm trying to see if there's any kind of join syntax that would return all the objects in a room for a given player's 'session'. Obviously it could be done with temporary tables, or just comparison outside of SQL, but I keep thinking this might be possible *somehow*

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".


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