Re: [PHP] php query for mysql table
You should use the like clause whch allows the use of wild cards % and ?. Have a look at the MySQL manual, it should be explained there. HTH Gianluca WS I am a newbie to php + mysql and wanted to ask for some help on a WS particular item which I can't seem to find the right key in the WS documentation. I am trying to set up a simple QA system with an entry WS page where one can select to either have all questions answers from a WS mysql database displayed or else search with a text field for only WS those questions which contain a certain word(s). WS Can someone tell me how to set in a query when trying to find records WS in a mysql table that have a certain word or perhaps 2 or 3 words WS (among others) ...? WS I know about using SELECT and WHERE in order to find records which WS match *exactly*, but am looking for something a bit different ... WS Example: WS The values of 3 records for the question field of the database might WS be the following: WS [1] How do you deal with anger? WS [2] Ever been full of anger in your life? WS [3] Is life always easy? WS How can I set a PHP query with SELECT and WHERE to express the WS following: WS Which questions contain the word life? That is, have someone search WS the database in the question field for records where the word life WS is used as part of the question ... The result then should return the WS records 2 3 above WS Any help is greatly appreciated. Thanks mucho. WS God bless you with His grace and peace WS Wolfgang WS Looking for Biblical information? COME AND SEE! WS -- ONLINE Courses: http://classes.bibelcenter.de ... NEW! WS -- BibelCenter: http://www.bibelcenter.de WS -- Bookstore: http://www.worthy.net/BibelCenter/ [EMAIL PROTECTED] BcnInédita EURO RSCG INTERACTION www.bcninedita.com Planella, 39 08017 Barcelona Tel.34 932 531 950 (directo 93 253 19 53) Fax. 34 932 114 546 -- 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]
RE: [PHP] php query for mysql table
% works as a wildcard in mySQL. Example: SELECT * FROM table WHERE Question LIKE '%life%' would return all rows with field Question containing string life. Niklas -Original Message- From: Wolfgang Schneider [mailto:[EMAIL PROTECTED]] Sent: 20. elokuuta 2001 13:22 To: php-general Subject: [PHP] php query for mysql table Hi I am a newbie to php + mysql and wanted to ask for some help on a particular item which I can't seem to find the right key in the documentation. I am trying to set up a simple QA system with an entry page where one can select to either have all questions answers from a mysql database displayed or else search with a text field for only those questions which contain a certain word(s). Can someone tell me how to set in a query when trying to find records in a mysql table that have a certain word or perhaps 2 or 3 words (among others) ...? I know about using SELECT and WHERE in order to find records which match *exactly*, but am looking for something a bit different ... Example: The values of 3 records for the question field of the database might be the following: [1] How do you deal with anger? [2] Ever been full of anger in your life? [3] Is life always easy? How can I set a PHP query with SELECT and WHERE to express the following: Which questions contain the word life? That is, have someone search the database in the question field for records where the word life is used as part of the question ... The result then should return the records 2 3 above Any help is greatly appreciated. Thanks mucho. God bless you with His grace and peace Wolfgang Looking for Biblical information? COME AND SEE! -- ONLINE Courses: http://classes.bibelcenter.de ... NEW! -- BibelCenter: http://www.bibelcenter.de -- Bookstore: http://www.worthy.net/BibelCenter/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- 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]
RE: [PHP] php query for mysql table
You can use the SQL keyword LIKE for this. Have a look at the MySQL docs for full info, but the idea is you'd do something like: $query = SELECT * FROM table WHERE question LIKE '%. $search_phrase. %'; HTH Jon -Original Message- From: Wolfgang Schneider [mailto:[EMAIL PROTECTED]] Sent: 20 August 2001 11:22 To: php-general Subject: [PHP] php query for mysql table Hi I am a newbie to php + mysql and wanted to ask for some help on a particular item which I can't seem to find the right key in the documentation. I am trying to set up a simple QA system with an entry page where one can select to either have all questions answers from a mysql database displayed or else search with a text field for only those questions which contain a certain word(s). Can someone tell me how to set in a query when trying to find records in a mysql table that have a certain word or perhaps 2 or 3 words (among others) ...? I know about using SELECT and WHERE in order to find records which match *exactly*, but am looking for something a bit different ... Example: The values of 3 records for the question field of the database might be the following: [1] How do you deal with anger? [2] Ever been full of anger in your life? [3] Is life always easy? How can I set a PHP query with SELECT and WHERE to express the following: Which questions contain the word life? That is, have someone search the database in the question field for records where the word life is used as part of the question ... The result then should return the records 2 3 above Any help is greatly appreciated. Thanks mucho. God bless you with His grace and peace Wolfgang -- 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]
RE: [PHP] php query for mysql table
On Mon, 20 Aug 2001 13:35:39 +0300, Niklas Lampén wrote: % works as a wildcard in mySQL. Example: SELECT * FROM table WHERE Question LIKE '%life%' would return all rows with field Question containing string life. Hello all helpers, well ... thanks to those who have already replied and helped me out here. I suppose it is when looking in the wrong place one can't quite find the right answer :-) I appreciate the mails and suggestions. It sure is nice to have a forum like this available ! Thanks ! God bless you with His grace and peace Wolfgang Looking for Biblical information? COME AND SEE! -- ONLINE Courses: http://classes.bibelcenter.de ... NEW! -- BibelCenter: http://www.bibelcenter.de -- Bookstore: http://www.worthy.net/BibelCenter/ -- 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]
Re: [PHP] php query for mysql table
select * from yourtable where question like '%life%' -- Original Message -- From: Wolfgang Schneider [EMAIL PROTECTED] Reply-To: Wolfgang Schneider [EMAIL PROTECTED] Date: Mon, 20 Aug 2001 12:22:15 +0200 Hi I am a newbie to php + mysql and wanted to ask for some help on a particular item which I can't seem to find the right key in the documentation. I am trying to set up a simple QA system with an entry page where one can select to either have all questions answers from a mysql database displayed or else search with a text field for only those questions which contain a certain word(s). Can someone tell me how to set in a query when trying to find records in a mysql table that have a certain word or perhaps 2 or 3 words (among others) ...? I know about using SELECT and WHERE in order to find records which match *exactly*, but am looking for something a bit different ... Example: The values of 3 records for the question field of the database might be the following: [1] How do you deal with anger? [2] Ever been full of anger in your life? [3] Is life always easy? How can I set a PHP query with SELECT and WHERE to express the following: Which questions contain the word life? That is, have someone search the database in the question field for records where the word life is used as part of the question ... The result then should return the records 2 3 above Any help is greatly appreciated. Thanks mucho. God bless you with His grace and peace Wolfgang Looking for Biblical information? COME AND SEE! -- ONLINE Courses: http://classes.bibelcenter.de ... NEW! -- BibelCenter: http://www.bibelcenter.de -- Bookstore: http://www.worthy.net/BibelCenter/ -- 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] -- 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]
RE: [PHP] php query for mysql table
Wolfgang, Use LIKE '%life%' as in SELECT somecolumn FROM mytable WHERE LOWER(mycolumn) LIKE '%life%' Don't forget to compare same case strings. Johan Alfredeen www.pongworld.com From mySQL manual: mysql SELECT * FROM tbl_name WHERE set_col LIKE '%value%'; mysql SELECT * FROM tbl_name WHERE FIND_IN_SET('value',set_col)0; -Original Message- From: Wolfgang Schneider [mailto:[EMAIL PROTECTED]] Sent: Monday, August 20, 2001 4:22 AM To: php-general Subject: [PHP] php query for mysql table Hi I am a newbie to php + mysql and wanted to ask for some help on a particular item which I can't seem to find the right key in the documentation. I am trying to set up a simple QA system with an entry page where one can select to either have all questions answers from a mysql database displayed or else search with a text field for only those questions which contain a certain word(s). Can someone tell me how to set in a query when trying to find records in a mysql table that have a certain word or perhaps 2 or 3 words (among others) ...? I know about using SELECT and WHERE in order to find records which match *exactly*, but am looking for something a bit different ... Example: The values of 3 records for the question field of the database might be the following: [1] How do you deal with anger? [2] Ever been full of anger in your life? [3] Is life always easy? How can I set a PHP query with SELECT and WHERE to express the following: Which questions contain the word life? That is, have someone search the database in the question field for records where the word life is used as part of the question ... The result then should return the records 2 3 above Any help is greatly appreciated. Thanks mucho. God bless you with His grace and peace Wolfgang Looking for Biblical information? COME AND SEE! -- ONLINE Courses: http://classes.bibelcenter.de ... NEW! -- BibelCenter: http://www.bibelcenter.de -- Bookstore: http://www.worthy.net/BibelCenter/ -- 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] -- 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]