Search the Whole World Here.,.,

SQL - BETWEEN Operator Example




The following SQL statement selects all products with a price BETWEEN 10 and 20:

Example

SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;

Try it Yourself »

SQL - LIKE Operator Examples

SQL - LIKE Operator Examples


The following SQL statement selects all customers with a City starting with the letter "s":

Example

SELECT * FROM Customers
WHERE City LIKE 's%';
Try it Yourself »
Tip: The "%" sign is used to define wildcards (missing letters) both before and after the pattern. You will learn more about wildcards in the next chapter.
The following SQL statement selects all customers with a City ending with the letter "s":

Example

SELECT * FROM Customers
WHERE City LIKE '%s';
Try it Yourself »
The following SQL statement selects all customers with a Country containing the pattern "land":

Example

SELECT * FROM Customers
WHERE Country LIKE '%land%';
Try it Yourself »
Using the NOT keyword allows you to select records that do NOT match the pattern.
The following SQL statement selects all customers with Country NOT containing the pattern "land":

Example

SELECT * FROM Customers
WHERE Country NOT LIKE '%land%';
Try it Yourself »

SQL - Delete All Data

SQL - Delete All Data


It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:
DELETE FROM table_name;

or

DELETE * FROM table_name;
Note: Be very careful when deleting records. You cannot undo this statement!

SQL - DELETE Example




Assume we wish to delete the customer "Alfreds Futterkiste" from the "Customers" table.

We use the following SQL statement:

Example

DELETE FROM Customers
WHERE CustomerName='Alfreds Futterkiste' AND ContactName='Maria Anders';
Try it Yourself »

SQL - UPDATE Multiple Records

SQL - UPDATE Multiple Records


In an update statement, it is the WHERE clause that determines how many records which will be updated.

The WHERE clause: WHERE Country='Mexico' will update all records which have the value "Mexico" in the field "Country".

Example

UPDATE Customers
SET ContactName='Juan'
WHERE Country='Mexico';
Try it Yourself »

SQL - UPDATE Multiple Columns

SQL - UPDATE Multiple Columns


To update more than one column, use a comma as seperator.

Assume we wish to update the customer "Alfreds Futterkiste" with a new contact person and city.

We use the following SQL statement:

Example

UPDATE Customers
SET ContactName='Alfred Schmidt', City='Frankfurt'
WHERE CustomerID=1;
Try it Yourself »

SQL - Combining AND & OR

SQL - Combining AND & OR


You can also combine AND and OR (use parenthesis to form complex expressions).

The following SQL statement selects all customers from the country "Germany" AND the city must be equal to "Berlin" OR "Mรผnchen", in the "Customers" table:

Example

SELECT * FROM Customers
WHERE Country='Germany'
AND (City='Berlin' OR City='Mรผnchen');
Try it Yourself »

SQL - OR Operator Example

SQL - OR Operator Example


The following SQL statement selects all customers from the city "Berlin" OR 

"Mรผnchen", in the "Customers" table: 

Example

SELECT * FROM Customers
WHERE City='Berlin'
OR City='Mรผnchen';
Try it Yourself »

SQL - AND Operator Example

SQL - AND Operator Example


The following SQL statement selects all customers from the country "Germany" AND the city "Berlin", in the "Customers" table:

Example

SELECT * FROM Customers
WHERE Country='Germany'
AND City='Berlin';
Try it Yourself »

SQL - Operators in The WHERE Clause

SQL - Operators in The WHERE Clause


The following operators can be used in the WHERE clause:
OperatorDescription
=Equal
<>Not equal.
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal
BETWEENBetween an inclusive range
LIKESearch for a pattern
INTo specify multiple possible values for a column

SQL - SELECT Column Example




The following SQL statement selects the "CustomerName" and "City" columns from the "Customers" table:

Example

SELECT CustomerName,City FROM Customers;
Try it Yourself »

SQL - Comments in Statements




To ignore just a part of a statement, use the /* */ comment.
Any text between /* and */ will be ignored.

Example

Ignore part of a line:
SELECT CustomerName, /*City,*/ Country FROM Customers;
Try it Yourself »

Example

Ignore a parts of a statment:
SELECT * FROM Customers WHERE (CustomerName LIKE 'L%'
OR CustomerName LIKE 'R%' /*OR CustomerName LIKE 'S%'
OR CustomerName LIKE 'T%'*/
 OR CustomerName LIKE 'W%')
AND Country='USA'
ORDER BY CustomerName;
Try it Yourself »

SQL - Multi-line Comments




Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored.

Example

A multi-line comment as an explanation:
/*Select all the columns
of all the records
in the Customers table:*/

SELECT * FROM Customers;
Try it Yourself »

Example

A multi-line comment to ignore many statements:
/*SELECT * FROM Customers;
SELECT * FROM Products;
SELECT * FROM Orders;
SELECT * FROM Categories;*/

SELECT * FROM Suppliers;
Try it Yourself »

SQL - Single Line Comments




Single line comments start with --.
Any line between -- and the end of the line will be ignored (will not be executed).

Example

A single-line comment as an explanation:
--Select all:SELECT * FROM Customers;
Try it Yourself »

Example

A single-line comment to ignore the end of a line:
SELECT * FROM Customers -- WHERE City='Berlin';
Try it Yourself »

Example

A single-line comment to ignore a statement:
--SELECT * FROM Customers;SELECT * FROM Products;
Try it Yourself »

Some of The Most Important SQL Commands



  • SELECT - extracts data from a database

  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT INTO - inserts new data into a database
  • CREATE DATABASE - creates a new database
  • ALTER DATABASE - modifies a database
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index
HTML Form - The Submit Button

HTML Form - The Submit Button


<input type="submit"> defines a button for submitting the form data to a form-handler.
The form-handler is typically a server page with a script for processing input data.
The form-handler is specified in the form's action attribute:

Example

<form action="action_page.php">
  First name:<br>
  <input type="text" name="firstname" value="Mickey"><br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse"><br><br>
  <input type="submit" value="Submit">
</form>
Try it Yourself »
This is how the HTML code above will be displayed in a browser:
First name:
 
Last name:
 

HTML Form - Radio Button Input

HTML Form - Radio Button Input


<input type="radio"> defines a radio button.
Radio buttons let a user select ONE of a limited number of choices:

Example

<form>
  <input type="radio" name="gender" value="male" checked> Male<br>
  <input type="radio" name="gender" value="female"> Female<br>
  <input type="radio" name="gender" value="other"> Other
</form>
Try it Yourself »
This is how the HTML code above will be displayed in a browser:
 Male
 Female
 Other
Following tips

Following tips


Friends please follow my blog to get direct updates in your mailbox.

Get direct mail to you about new posts and updates.

Thanking You

Abhishek Gupta

HTML Form - Text Input

HTML Form - Text Input


<input type="text"> defines a one-line input field for text input:

Example

<form>
  First name:<br>
  <input type="text" name="firstname"><br>
  Last name:<br>
  <input type="text" name="lastname">
</form>
Try it Yourself »
This is how it will look like in a browser:
First name:

Last name:
Note: The form itself is not visible. Also note that the default width of a text field is 20 characters.

Ads by Google