sql-my blog on sql

Tuesday, December 05, 2006

AND OR

we have seen that the WHERE keyword can be used to conditionally select data from a table. This condition can be a simple condition (like the one presented in the previous section), or it can be a compound condition. Compound conditions are made up of multiple simple conditions connected by AND or OR. There is no limit to the number of simple conditions that can be present in a single SQL statement.

The syntax for a compound condition is as follows:

SELECT "column_name"
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"}+

The {}+ means that the expression inside the bracket will occur one or more times. Note that AND and OR can be used interchangeably. In addition, we may use the parenthesis sign () to indicate the order of the condition.

AND OR

we have seen that the WHERE keyword can be used to conditionally select data from a table. This condition can be a simple condition (like the one presented in the previous section), or it can be a compound condition. Compound conditions are made up of multiple simple conditions connected by AND or OR. There is no limit to the number of simple conditions that can be present in a single SQL statement.

The syntax for a compound condition is as follows:

SELECT "column_name"
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"}+

The {}+ means that the expression inside the bracket will occur one or more times. Note that AND and OR can be used interchangeably. In addition, we may use the parenthesis sign () to indicate the order of the condition.

Wednesday, November 15, 2006

distinct




SELECT DISTINCT "column_name"
FROM "table_name"

The SELECT keyword allows us to grab all information from a column (or columns) on a table. This, of course, necessarily mean that there will be redundancies. What if we only want to select each DISTINCT element? This is easy to accomplish in SQL. All we need to do is to add DISTINCT after SELECT.

Monday, November 13, 2006

where

SELECT "column_name"
FROM "table_name"
WHERE "condition"

this will show the results as we specify in where clause
like a particular name, or employess of particular age

it will be like

select name from employee
where age=21;

it will show name of all employees of age 21

SQL commands: select

SELECT "column_name" FROM "table_name"

the two keywords that are used are column name and table name:

that will select the particular information from the table...

a particular example can be

select name from employee;

which will show all the names of employees from the employee table....