Powered by InterCreatives | Site Map
Search:
NewSourceMedia Popular Tutorials: PHP Javascripts Web Hosting
SoftwareTutorials
CATEGORIES
Job Listings
 
Home / PHP / MySQL / Database

PHP Search using WHERE, AND, LIKE, OR Query Functions

Published by: Alex


Search using WHERE, AND, LIKE, OR Query Functions

  1. Looking for an exact match in field1:
    SELECT * FROM table WHERE field1 = '$name'
  2. Looking if the field1 contains the search word anywhere using LIKE and both '%%'
    SELECT * FROM table WHERE field1 LIKE '%$word%'
  3. Looking if the field1 contains the value that begins with our word using LIKE and the last ' %'
    SELECT * FROM table WHERE field1 LIKE '$word%'
  4. Looking if the field1 contains the value that ends with our word using LIKE and the first '% '
    SELECT * FROM table WHERE field1 LIKE '%$word'
  5. Looking if our search word appears in both fields using AND
    SELECT * FROM table WHERE field1 LIKE '%$word%' AND field2 LIKE '%$word%'
  6. Looking if our search word appears in any of the two fields using OR
    SELECT * FROM table WHERE field1 LIKE '%$word%' OR field2 LIKE '%$word%'
  7. Looking if our word is in field1 OR in field2 AND field3 using Parentheses
    SELECT * FROM table WHERE field1 LIKE '%$word%' OR (field2 LIKE '%$word%' AND field2 LIKE '%$word%') ORDER BY id DESC

 


Next PHP Page:
1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  [19]  20  21  22  23  24  25  26  27  28  29  30  31  32 





Hosting by iPowerWeb.com - 50 Gb for $7.95