Friday 19, December 2014
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    About Us    |    Contact Us

Where Clause

In Select Query we use WHERE clause to select only data that matches a specified criteria.

 

Syntax
SELECT column(s) FROM tablename WHERE column operator value

 

Example:
            Table Name(empinfo)
FirstName
LastName
Email
DOB
Steve
Martin
smart.steve@studiesinn.com
08-04-1988
David
Fernandas
davidfernandas@studiesinn.com
04-16-1977
Ajay
Rathor
ajayrathor@studiesinn.com
08-24-1986

 

$con = mysql_connect("localhost:3306","adam","123456");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());

  }

mysql_select_db("mydb", $con);
$result = mysql_query("SELECT * FROM empinfo where FirstName=’David’");
while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'] . “ “ $row[‘DOB’];
  echo "
";
  }
mysql_close($con);
?>

 

Output will be.

David Fernandas 04-16-1977

 

Operator that can be used in where clause are as under
= Equal
!= Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
 
     
   
PHP Tutorial
 
  Introduction
Introduction
  Variables
Variables
  Strings
Strings
  Operators
Operators
  If Else Statement
If Else Statement
  Loops
Loops
  Functions
Functions
  Forms
Forms
  Sessions
Sessions
  Cookies
Cookies
  Files
Files
  E-mail
E-mail
  Error Handling
Error Handling
  File Upload
File Upload
  PHP Databases
PHP Databases
  Connecting to a MySQL Database
Connecting to a MySQL Database
  MySQL Data Types
MySQL Data Types
  Inserting Data Into a Table
Inserting Data Into a Table
  Select Statement
Select Statement
  Where Clause
Where Clause
  Order By
Order By
  Update Statement
Update Statement
  Delete From Statement
Delete From Statement
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download The 7 Great Lies of Network Marketing  Ebook The 7 Great Lies of Network Marketing
   
Download The Leading Affiliate Money Machine Ebook The Leading Affiliate Money Machine
   
Download Guide To Cashing In On Ebay  Ebook Guide To Cashing In On Ebay
   
Download Linux Internals (to the power of -1)  Ebook Linux Internals (to the power of -1)
   
Download How To Really Earn Big With Your Own Internet Business  Ebook How To Really Earn Big With Your Own Internet Business
   
     
Studiesinn.com 2014 All Rights Reserved.
 
Website Designed & Developed by TechXprtz