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


RE: [PHP] Re: SQL Query

2003-02-15 Thread Willie G
Zydox,

Please define 'sub-interest'.  I've looked at what Uttam gave you, and it
looks correct, assuming you want want it limited to the same user.  If you
result should be 'all with Interest = X and Valid = Y, just remove the
userid from the second query.

SELECT
InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
InterestsList.Valid
FROM InterestsIndex
INNER JOIN InterestList
ON InterestIndex.InterestID=InterestList.ID
WHERE
InterestList.SubID='3' AND
InterestList.Valid='1'


- Larry

-Original Message-
From: Zydox [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 15, 2003 7:58 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: SQL Query


Those querys work... but they don't get all the Sub Interests...

Uttam [EMAIL PROTECTED] wrote in message
97FB62E1E350D511B71F00A0C99D0CC30352D563@MSEXCHANGE">news:97FB62E1E350D511B71F00A0C99D0CC30352D563@MSEXCHANGE...
 if i understand you correctly then this should give valid interests of a
 user:

 SELECT DISTINCT
 InterestsList.SubID
 FROM
 InterestsIndex INNER JOIN InterestList
 ON InterestIndex.InterestID=InterestList.ID
 WHERE
 InterestIndex.UserID='1' AND
 InterestList.Valid='1'

 and if the chosen interest is '3' then valid subinterests are:

 SELECT
 InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
 InterestsList.Valid
 FROM
 InterestsIndex INNER JOIN InterestList
 ON InterestIndex.InterestID=InterestList.ID
 WHERE
 InterestIndex.UserID='1' AND
 InterestList.SubID='3' AND
 InterestList.Valid='1'

 regds,
 -Original Message-
 From: Zydox [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, February 15, 2003 09:48
 To: [EMAIL PROTECTED]
 Subject: SQL Query


 I have a problem writing a query that can select a Interest for a specific
 user... There are tvo tables, IList and IIndex...
 IList contains this :
   ID  SubID  Interest  Valid
   Edit  Delete  1 0 Datorer 0
   Edit  Delete  2 1 Spel 0
   Edit  Delete  3 2 Strategi 0
   Edit  Delete  4 3 Star Craft 1
   Edit  Delete  5 3 Star Wars: Gallactic Battelinggrounds 1
   Edit  Delete  6 2 Shoot-Em-Up 0
   Edit  Delete  7 6 Half-Life 0
   Edit  Delete  8 7 Team Fortress 1
   Edit  Delete  9 7 Counter-Strike 1


 And IIndex contains a UserID And InterestID... this query :
 SELECT DISTINCTROW InterestsList.ID, InterestsList.SubID,
 InterestsList.Interest, InterestsList.Valid FROM InterestsList AS II RIGHT
 JOIN InterestsList ON InterestsList.ID=II.SubID LEFT JOIN InterestsIndex
ON
 InterestsList.ID=InterestsIndex.InterestID AND InterestsIndex.UserID='1'

 Selects all rows from IList... even if there Is'nt any instans in IIndex..
.
 this thougt is that a User can choose a Valid Interest and then the
query
 should select all SubInterests... anyone know how to do that ?

 // Regards Zydox






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




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




Re: [PHP] Re: SQL Query

2003-02-15 Thread Zydox
The result recived from that query is this
ID  SubID  Interest  Valid
  Edit  Delete  4 3 Star Craft 1


But I want a Query that retrives
Star Craft, Strategi, Spel and Datorer... :/

Willie G [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Zydox,

 Please define 'sub-interest'.  I've looked at what Uttam gave you, and it
 looks correct, assuming you want want it limited to the same user.  If you
 result should be 'all with Interest = X and Valid = Y, just remove the
 userid from the second query.

 SELECT
 InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
 InterestsList.Valid
 FROM InterestsIndex
 INNER JOIN InterestList
 ON InterestIndex.InterestID=InterestList.ID
 WHERE
 InterestList.SubID='3' AND
 InterestList.Valid='1'


 - Larry

 -Original Message-
 From: Zydox [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, February 15, 2003 7:58 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: SQL Query


 Those querys work... but they don't get all the Sub Interests...

 Uttam [EMAIL PROTECTED] wrote in message
 97FB62E1E350D511B71F00A0C99D0CC30352D563@MSEXCHANGE">news:97FB62E1E350D511B71F00A0C99D0CC30352D563@MSEXCHANGE...
  if i understand you correctly then this should give valid interests of a
  user:
 
  SELECT DISTINCT
  InterestsList.SubID
  FROM
  InterestsIndex INNER JOIN InterestList
  ON InterestIndex.InterestID=InterestList.ID
  WHERE
  InterestIndex.UserID='1' AND
  InterestList.Valid='1'
 
  and if the chosen interest is '3' then valid subinterests are:
 
  SELECT
  InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
  InterestsList.Valid
  FROM
  InterestsIndex INNER JOIN InterestList
  ON InterestIndex.InterestID=InterestList.ID
  WHERE
  InterestIndex.UserID='1' AND
  InterestList.SubID='3' AND
  InterestList.Valid='1'
 
  regds,
  -Original Message-
  From: Zydox [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, February 15, 2003 09:48
  To: [EMAIL PROTECTED]
  Subject: SQL Query
 
 
  I have a problem writing a query that can select a Interest for a
specific
  user... There are tvo tables, IList and IIndex...
  IList contains this :
ID  SubID  Interest  Valid
Edit  Delete  1 0 Datorer 0
Edit  Delete  2 1 Spel 0
Edit  Delete  3 2 Strategi 0
Edit  Delete  4 3 Star Craft 1
Edit  Delete  5 3 Star Wars: Gallactic Battelinggrounds 1
Edit  Delete  6 2 Shoot-Em-Up 0
Edit  Delete  7 6 Half-Life 0
Edit  Delete  8 7 Team Fortress 1
Edit  Delete  9 7 Counter-Strike 1
 
 
  And IIndex contains a UserID And InterestID... this query :
  SELECT DISTINCTROW InterestsList.ID, InterestsList.SubID,
  InterestsList.Interest, InterestsList.Valid FROM InterestsList AS II
RIGHT
  JOIN InterestsList ON InterestsList.ID=II.SubID LEFT JOIN InterestsIndex
 ON
  InterestsList.ID=InterestsIndex.InterestID AND
InterestsIndex.UserID='1'
 
  Selects all rows from IList... even if there Is'nt any instans in
IIndex..
 .
  this thougt is that a User can choose a Valid Interest and then the
 query
  should select all SubInterests... anyone know how to do that ?
 
  // Regards Zydox
 
 
 



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





begin 666 fulltext.png
MB5!.1PT*@H-24A$4@```#(4 8```#/RFZ:ITE$051XG.V6
MR1 ( P`,4,??S _JN@`![:/I8X,L3 N$]0V1DS;K+@8`OA:HA:0.
ML,R*]+\VU5!/%7Y ++J*M6K:QC#%.1*!#JFG^;G!^4?,2-E=@G9P)?66J
ML32H6IOX:1*769T.T@GY@[4X97SNS)?SA%1C#X2^@'5R)49';_@\GYC7LA
L]LHP@9 ?C1@M]UMQ1:Q]4X-.2# ?!$EN\TUU7#PD`245.1*Y8((`
`
end


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




RE: [PHP] Re: SQL Query

2003-02-15 Thread Willie G
Zydox,

Your request does not make sense.  There must be other fields you want to
link, because if we go back you your original data, these records are
unrelated.  The 'SubID' of Star Craft and Star Wars match.  The 'Valid' of
Star Craft, Star Wars, Team Fortress, and Counter-Strike match.  Datorer and
Strategi have nothing in common with the other items in your list, or each
other.  Unless you have another table or additional field that have not been
provided in this thread, you have no way to relate those elements to each
other.   Below is your original data provided:

ID  SubID  Interest  Valid
1 0 Datorer 0
2 1 Spel 0
3 2 Strategi 0
4 3 Star Craft 1
5 3 Star Wars: Gallactic Battelinggrounds 1
6 2 Shoot-Em-Up 0
7 6 Half-Life 0
8 7 Team Fortress 1
9 7 Counter-Strike 1

- Larry

-Original Message-
From: Zydox [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 15, 2003 11:01 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: SQL Query


The result recived from that query is this
ID  SubID  Interest  Valid
  Edit  Delete  4 3 Star Craft 1


But I want a Query that retrives
Star Craft, Strategi, Spel and Datorer... :/

Willie G [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Zydox,

 Please define 'sub-interest'.  I've looked at what Uttam gave you, and it
 looks correct, assuming you want want it limited to the same user.  If you
 result should be 'all with Interest = X and Valid = Y, just remove the
 userid from the second query.

 SELECT
 InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
 InterestsList.Valid
 FROM InterestsIndex
 INNER JOIN InterestList
 ON InterestIndex.InterestID=InterestList.ID
 WHERE
 InterestList.SubID='3' AND
 InterestList.Valid='1'


 - Larry

 -Original Message-
 From: Zydox [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, February 15, 2003 7:58 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: SQL Query


 Those querys work... but they don't get all the Sub Interests...

 Uttam [EMAIL PROTECTED] wrote in message
 97FB62E1E350D511B71F00A0C99D0CC30352D563@MSEXCHANGE">news:97FB62E1E350D511B71F00A0C99D0CC30352D563@MSEXCHANGE...
  if i understand you correctly then this should give valid interests of a
  user:
 
  SELECT DISTINCT
  InterestsList.SubID
  FROM
  InterestsIndex INNER JOIN InterestList
  ON InterestIndex.InterestID=InterestList.ID
  WHERE
  InterestIndex.UserID='1' AND
  InterestList.Valid='1'
 
  and if the chosen interest is '3' then valid subinterests are:
 
  SELECT
  InterestsList.ID, InterestsList.SubID, InterestsList.Interest,
  InterestsList.Valid
  FROM
  InterestsIndex INNER JOIN InterestList
  ON InterestIndex.InterestID=InterestList.ID
  WHERE
  InterestIndex.UserID='1' AND
  InterestList.SubID='3' AND
  InterestList.Valid='1'
 
  regds,
  -Original Message-
  From: Zydox [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, February 15, 2003 09:48
  To: [EMAIL PROTECTED]
  Subject: SQL Query
 
 
  I have a problem writing a query that can select a Interest for a
specific
  user... There are tvo tables, IList and IIndex...
  IList contains this :
ID  SubID  Interest  Valid
Edit  Delete  1 0 Datorer 0
Edit  Delete  2 1 Spel 0
Edit  Delete  3 2 Strategi 0
Edit  Delete  4 3 Star Craft 1
Edit  Delete  5 3 Star Wars: Gallactic Battelinggrounds 1
Edit  Delete  6 2 Shoot-Em-Up 0
Edit  Delete  7 6 Half-Life 0
Edit  Delete  8 7 Team Fortress 1
Edit  Delete  9 7 Counter-Strike 1
 
 
  And IIndex contains a UserID And InterestID... this query :
  SELECT DISTINCTROW InterestsList.ID, InterestsList.SubID,
  InterestsList.Interest, InterestsList.Valid FROM InterestsList AS II
RIGHT
  JOIN InterestsList ON InterestsList.ID=II.SubID LEFT JOIN InterestsIndex
 ON
  InterestsList.ID=InterestsIndex.InterestID AND
InterestsIndex.UserID='1'
 
  Selects all rows from IList... even if there Is'nt any instans in
IIndex..
 .
  this thougt is that a User can choose a Valid Interest and then the
 query
  should select all SubInterests... anyone know how to do that ?
 
  // Regards Zydox
 
 
 



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








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