You are here: Articles > Computers & Technology > sql

 See more articles about "sql "

Tutorial Addendum on SQL - Operations and Expressions



 31 December 18:00   

    



    



    

Predicate Operations

    



    

Predicate operations are operations that can be evaluated to accord a action

    

of true or false:

    



    

1. "Comparison" Predicates: Compares two ethics of the aforementioned blazon according to

    

a predefined order. There are 6 allegory operations:

    



        

  • Equal: amount = value

        



  •     

  • Not Equal: amount <> value

        



  •     

  • Less Than: amount < value

        



  •     

  • Greater Than: amount > value

        



  •     

  • Less Than or Equal: amount <= value

        



  •     

  • Greater Than or Equal: amount >= value

        



  •     



    



    

2. "Between" Predicates: Analysis a accustomed amount adjoin a amount range.

    

There are 2 "between" operations:

    



        

  • Between: amount Amid amount AND value

        



  •     

  • Not Between: amount NOT Amid amount AND value

        



  •     



    



    

3. "In" Predicates: Analysis a accustomed amount adjoin a account of values.

    

There are 2 "in" operations:

    



        

  • In: amount IN (value, value, ..., value)

        



  •     

  • Not In: amount NOT IN (value, value, ..., value)

        



  •     



    



    

4. "Like" Predicates: Analysis a accustomed appearance cord adjoin a character

    

pattern. By absence "Like" operations are not case sensitive.

    

There are 2 "Like" operations:

    



        

  • Like: cord LIKE pattern

        



  •     

  • Not Like: cord NOT LIKE pattern

        



  •     



    



    

"pattern" is a appearance cord with wildcard characters and escape sequences:

    



        

  • "_": Apery one and alone one individual character.

        



  •     

  • "%": Apery zero, one and some characters.

        



  •     

  • "\_": Apery appearance "_".

        



  •     

  • "\%": Apery appearance "%".

        



  •     



    



    

Examples:

    

 

    

abc LIKE Abc -- true

    

3.14 LIKE _.__ -- true

    

3.14159 LIKE 3.% -- true

    

_yang LIKE \_yang -- true

    

4.75% LIKE _.__\% -- true

    



    



    

5. "Null" Predicates: Analysis a accustomed amount adjoin absent value.

    

There are 2 "Null" operations:

    



        

  • Null: amount IS NULL

        



  •     

  • Not Null: amount IS NOT NULL

        



  •     



    



    

Examples:

    

 

    

1 IS Absent -- false

    

a IS NOT Absent -- true

    

NULL IS Absent -- true

    

NULL IS NOT Absent -- false

    



    



    



    

Date and Time Operations

    



    

The alotof frequently acclimated date and time operations are:

    



        

  • data_time_value + interval_value

        



  •     

  • data_time_value - interval_value

        



  •     

  • interval_value + data_time_value

        



  •     



    



    

Examples:

    

 

    

DATE 1999-01-01 + Breach 3 MONTH

    

DATE 2000-03-01 - Breach 1 DAY -- watch out bound years!

    

INTERVAL 48 HOUR + TIMESTAMP 1999-01-01 00:00:00

    



    



    



 


 value, operations, predicates, interval, character, string, representing, check, equal, given, , predicates check, value value, equal value, null value, time value, value not, given value, value <, operations are, value against, given value against, time value interval, data time value, value value value, < valuegreater than,

Share Tutorial Addendum on SQL - Operations and Expressions:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Tutorial Addendum on SQL - Operations and Expressions
Operation ExamplesExample 1 NumericOps.sql NumericOps.sql Absorb (c) 1999 by Dr. Yang SELECT 1 + 2 AS LINE_1;SELECT 2 / 3 AS LINE_2;

Tutorial Addendum on SQL - MySQL - Stored Procedures
This affiliate describes:What is a stored procedure?How to make a stored procedure.How to canyon data through parameters.

Tutorial Addendum on SQL - MySQL - Stored Procedures
Here is a simple analysis on stored action the MySQL applicant tool: mysql USE test; mysql DELIMITER / ;mysql Make Action Msg() BEGIN Baddest CURRENT_TIME() AS Time;br

Tutorial Addendum on SQL - MySQL - Stored Action Accent
This affiliate describes:Local variables in stored procedures.Execution breeze ascendancy statements.Cursor accompanying statements.br

Tutorial Addendum on SQL - MySQL - Stored Action Accent
Below is a sample cipher that uses a while bend to admit assorted rows into a table: ProcedureLoop.sql Absorb (c) 2004 by Dr. Yang DROP2 DATABASE IF EXISTS HyTest;CREATE DATABASE H

Tutorial Addendum on SQL - MySQL - Stored Action Accent
CursorsA cursor is a data blazon that represents a affiliation handle to the achievement table of a baddest statement. A cursor is actual agnate to a book handle in some additional programm

Tutorial Addendum on SQL - Baddest Statements
Select StatementsA baddest account is aswell alleged a concern statement. It is commonly acclimated to retrieve rows of data called from defined tables. The all encompassing syntax

Tutorial Addendum on SQL - Baddest Statements
Join TablesA accompany table is the achievement table of a accompany operation on two tables. There are several types of joinoperations:1. Cantankerous Accomp

Tutorial Addendum on SQL - Baddest Statements
JointTable.sql Archetype of Accompany TablesTo validate the accompany table logics mentioned in the antecedent section, I wrote thefollowing SQL code, JointTable.sql:

Tutorial Addendum on SQL - Baddest Statements
GROUP BY Clause"GROUP BY clause" modifies the abject table by alignment aboriginal rows into accumulation rows based on identical accumulated ethics of the defined accumulation columns. br