[PHP] Re: sql query question

2004-02-12 Thread Ben Ramsey
This is a SQL question, rather than a PHP question, so I would suggest 
doing a google search on SQL tutorials, but I think what you are trying 
to do would work like this:

SELECT * FROM table WHERE descript LIKE '%new%' OR descript LIKE '%car%'



Tony wrote:

hi

if i have  new  car and i want to search
each word in description
can i do
SELECT * FROM table WHERE
descript = new OR descript =car??
any help is appreciated
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: sql query question

2004-02-12 Thread Steve Solomon
select * from table where locate(new,descript)0 or
locate(car,descript)0;

Tony [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
hi

if i have  new  car and i want to search
each word in description
can i do
SELECT * FROM table WHERE
descript = new OR descript =car??

any help is appreciated

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: sql query question

2004-02-12 Thread Hamid Hossain
Hi,

It is better to use FullText. Convert the description field to FullText. You 
will gain a powerfull control in this case. For more information on how to 
use FullText read a little-bit in the MySql manual (MATCH AGAINST) commands.

Regards,
Hamid Hossain
---
Check Amazon.com Latest PHP books:
http://www.amazon.com/exec/obidos/redirect?tag=zawraqclassif-20path=tg/browse/-/295223
Start Accepting CreditCard at your site in minutes:
http://www.2checkout.com/cgi-bin/aff.2c?affid=106720
Download Alexa Tool Bar to stop Pop-ups for FREE:
http://download.alexa.com/?amzn_id=zawraqclassif-20
Download Ready-Made Templates for your site:
http://www.aplustemplates.com/cgi/affiliates/c1.cgi/zawraq_ad
Original Message Follows
From: Ben Ramsey [EMAIL PROTECTED]
To: [EMAIL PROTECTED], tony [EMAIL PROTECTED]
Subject: [PHP] Re: sql query question
Date: Thu, 12 Feb 2004 16:05:16 -0500
This is a SQL question, rather than a PHP question, so I would suggest doing 
a google search on SQL tutorials, but I think what you are trying to do 
would work like this:

SELECT * FROM table WHERE descript LIKE '%new%' OR descript LIKE '%car%'



Tony wrote:

hi

if i have  new  car and i want to search
each word in description
can i do
SELECT * FROM table WHERE
descript = new OR descript =car??
any help is appreciated
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: SQL Query Question

2001-12-09 Thread Fred

You could simply execute a second query where score  $score and return the
number of rows in the result + 1.

For instance:

$return = mysql_query(select ID, Name, Score, COUNT(Name) as total from
members where ID = '$ID');
$row = mysql_fetch_assoc($return);
extract ($row);
$return = mysql_query(select * from members where Score  '$Score');
$rank = mysql_num_rows($return) + 1;
echo $Name is ranked $rank of  $total;

Fred


Andrew Brampton [EMAIL PROTECTED] wrote in message
00c101c18029$8b2ed040$2528260a@STUDENT5830">news:00c101c18029$8b2ed040$2528260a@STUDENT5830...
Hi,
This isn't a php question, more of a SQL question, but I don't know any
where better to send it, and I guess its trival enough for someone here to
answer.

Anyway, I have a list of members each with a score field. How can I say that
Member 3 is ranked 10 out of 100 members for example.

Here is the layout of the members table:
ID, Name, Score

I can get the total count of members in the table, but I don't know how to
determine what rank they are, unless I return all the rows in the table
(sorted), and cycle through them until I find the member I want, counting
how many people are above him... This method would work, but would be slow
(and wastful), is there a better way to determine his position with a SQL
Query?

Thanks in advance
Andrew

P.S
If it matters I'm using MySQL  PHP 4.0.6 on WinXP under Apache 1.3.22




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]