• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Saturday, October 6, 2012

LOOPING IN MYSQL


Hi.. welcome to my blog.. You are on “We Are Knowledge”. The blog with to fill many IT knowledge.. IT knowledge from basic until hard. I was present many it knowledge for you, from desktop programming until web programming.


Sample of desktop programming is program language Pascal, cobol, c++ and other. And sample for web programming is Php, MySQL, javascript. I also present you about design graphic likely adobe photoshop. But bit tutorial about it.
Now.. I want giving you tutorial about “MySQL” again, but with different tutorial. 


Proeviously I was made tutorial about “condition In Mysql”. And for this article about “Looping  In Mysql”.. you will know ?? let’s do it now… have fun to read friends..


1. Looping

looping's purpose all the same with if's purpose, since core of both to sort statement until meets expected point it.


So looping at Mysql is condition to make a statement will perpetually happen until that statement as statement which is expected.


this is function of looping :

1. to print same process
2. to print same statement
3. to sort point


there is three repetitive form in Mysql, which is:

1. LOOP – AND LOOP

General form :

[ label : ] LOOP
            Statement
END LOOP [ label ];


2. REPEAT – UNTIL – END REPEAT

General form :

[ label : ] REPEAT
Statement
UNTIL expression
END REPEAT [ label ]


3. WHILE – END WHILE

General form :

[ label : ] WHILE expression DO
            Statements
END WHILE [ label ]


And this example looping, you can try it !!

Example 1 :

SET a = 1
V_loop : WHILE a <= 5 DO
            IF MOD (a, 2) = 0 THEN
                        SELECT CONCAT (a, “  Is round”);
            END IF
SET a = a + 1;
END WHILE v_loop;


To result :

0 is round
2 is round
4 is round


Ok.. just it..
I hope you likely..
See you laters

Thursday, October 4, 2012

CONDITION IN MYSQL


Hi.. welcome to my blog at “We Are Knowledge”.. In here you will getting amany IT knowledge, from desktop programming until web programming you can get it.. You can take it Free, so you must readcthis article in order to you having IT knowledge about it..


Still with tutorial about “MySQL” and now, I want giving you IT knowledge about “Condition In MySQL”.. You know it ?? if do not, let’s do read this article..


Condition in mysql is syntax used for doing selection from many options, and we must choice I (one) from many options. Likely other program language, condition in MySQL also using “IF”.


In MySQL to be found 3 (three) conditions, namely :

1. IF;
2. IF ELSE and;
3. CASE


Ok .. I want start from number 1 (one) until number 3 (three)


1. IF

Statement if used if only 1 (one) option or condition. If the value is right then getting result. And this general form :

IF select_condition THEN
Your_command_if_condition_is_right;
END IF;


Example 1 :

IF x > 5 THEN
Set sal = ‘biggest’;
END IF


2. IF ELSE

Statement “IF ELSE” used if you having more than one condition or option.
General form :

IF select_condition THEN
Your_command_if_condition_is_true;
ELSE
Your_command_if_condition_is_false;
END IF;


Example 2:

IF x > 5 THEN
Set sal = ‘biggest’;
ELSE
Set sal = ‘smallest’;
END IF


3. CASE

Likely if command, this syntax also for choice one option from other options. But usually this syntax used if you having many options, and if the condition has been true then program direct exit without execute other command.
General form :

CASE select_expression
WHEN value THEN
Write_statement_1;
[WHEN value THEN
Write_statement_2 … ]


Example 3:


CASE
WHEN (sal > 10) THEN
SET commission = 200;
WHEN (sal > 5) THEN
SET commission = 100;
WHEN (sal > 2) THEN
SET commission = 50;
ELSE SET commission = 20;
END CASE;



Ok just it..
Thanks was reading my article…
See you later..

Tuesday, October 2, 2012

MAKING, CHANGE, DELETING FUNCTION AND PROCEDURE IN MYSQL


Hai friends… this article is the next from function and procedure… C’mon read this.. previosuly I giving you tutorial about “function and procedure in MySQL”, that is introduction, and now I want giving you method making it (function and procedure)… 


And tutorial for this article :

1. Making Function And Procedure
2. Change Function And Procedure
3. Deleting Function And Procedure

Yes, that is material for today.. Ok.. I want start from number 1 (one)..


1. Making Function And Procedure

For making Function And Procedure we can using the syntax “create”. And this general form :

Example 1 :

CREATE
[ DEFINER = { user | CURRENT_USER } ]
FUNCTION select_sp_name ( [ select_function_paremeter [ , . . . ] ] )
RETURNS type
[ select_characteristic …] routine_body


And this example  procedure :

Example 2 :

DELIMETER $$
CREATE PROCEDURE hardware_count()
BEGIN
SELECT COUNT (*) FROM hardware;
END$$
DELIMETER;


And for working (execute) we are can used “call” and this query :

CALL hardware_count(@hardware)

Then

SELECT @hardware AS ‘hardware_count’ ;

hardware_count
7


2. Change Function And Procedure

Following function to change the function and procedure. This function is used apabaila we want to change the function and procedure without removing it first. And this is the general form :

ALTER [ PROCEDURE | FUNCTION ] select_pf_name
[ characteristic … ]

Example 3 :

DELIMETER $$
ALTER PROCEDURE hardware_count()
BEGIN
SELECT MAX (*) FROM hardware;
END$$
DELIMETER;


3. Deleting Function And Procedure

In accordance with the command (DML) are: insert, update, delete. then the function and procedure there is also a command to remove it. and this general form :

DROP [ PROCEDURE | FUNCTION ] [ IF EXISTS ] select_fp_name

Explanation :

Drop
>> syntax to remove the function and procedure

Procedure
>> if you are going to remove is the procedure the procedure to select the function you do not need to write

Function
>> opposite of the procedure, ie if you are going to remove is a function then select the function you do not need to write the procedure

If Exists
>> to see where the file is there or not

Select_fp_name
>> to select a function or procedure to be deleted

Ok.. just it…
See you later friends

FUNCTION AND PROCEDURE IN MYSQL


Still program language “MySQL”.. but with different tutorial. If previously my tutorial is “View in MySQL” then my new tutorial is “Function and Procedue MySQL”. Function in MySQL very significant presence in MySQL. Because function in Mysql used for make up a simple program andc for execute the program.


You know define from Function in MySQL ?? Function in MySQL is set of commands or statement can be saved and can be execute in MySQL database.. We are program can be efficient and effective


And this advantage in using the procedure :

A. Faster

Because the syntax or query that we use will be directly executed or executed on the server. Slightly different if we run the query or the execution of a programming language, for he will go back - behind well as between client to server


B. No Duplication Process

Because MySQL programming languages ​​we know the "primary Key", which is to give the index of a row in order to record the presence of a distinct initials in a column


C. Easy To Maintain

This advantage may be the continuation of benefits "No Duplication Process". because if the same data resulted in us is difficult to distinguish one data degan other data. Because in addition there is a "primary key" to differentiate the key in a table we can also use the "unique" whose function is similar to the "primary key"


D. More Database Security Guaranteed

With the use of a stored procedure would be safer, because the use of storage procedure we do not need to know the information contained in a table when we are required to display a table. As an example, we give a client access to add a record. then he can add (record). but he can only add to it and he can not see the contents of a table


Ok.. just it..
I hope you understand…
See you later..

Sunday, September 30, 2012

VIEW IN MYSQL


Mysql is is a desktop-based programming languages​​, and can also be web-based, because the programming language we often make the MySQL database, which often coexists with PHP. And PHP is a Web-based programming base.


Still the subject of MySQL, but with a different material. Previously I have discussed about the "trigger in mysql" .. Are you already understand the way users or know the function .. If you have not read it, please look at my blog, with the keyword "trigger in mysql".


And for the matter this time I will explain tentan "Views in MySQL" .. whether previously adan have understood the subject this time? or you've never read it, so you do not know this. Therefore let's read this article, and is secured by reading this article your knowledge about views in MySQL will increase ..


1. Views

Views in MySQL is a virtual form of a table view. And Views on the mysql query has been around since the release of MySQL version 5.0. Commands have similar views with the command "select". Since both of these commands are used to display the contents of data (records) from a table contained in a database.


2. Creating Views

Command views are actually used to display multiple columns (fields) of a table atanpa should perform filtering first.


And here's how to create views :

CREATE
[ OR REPLACE ]
[ ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE} ]
[ DEFINER = {user | CURRENT_USER} ]
[ SQL SECURITY {DEFINER | INVOKER} ]
VIEW view_of_name [ (list_of_column) ]
AS select_your_statement
[ WITH [ CASCADED | LOCAL ] CHECK OPTION ]


This is an example if you want to display the name of the hardware and the hardware price of the hardware table :


CREATE VIEW ‘little_part_of_hardware’
AS (select hardware_name, hardware_price
FROM hardware )


3. Deleting View

Removal of view also be useful, which is to reduce the capacity of our database, then the delete command view is created, and this is the command :

DROP VIEW little_part_of_hardware;


Ok.. just it…
I hope you understand..
See you later

Saturday, September 29, 2012

TRIGGER IN MYSQL


Hello my friends the IT knowledge lovers… You are  on my blog  at “We Are Knowledge”.. in here you want to getting and take many IT knowledge, you can get it FREE. You are was choice the right blog, because this is blog to fill many IT knowledge..

Likely this article, discuss about program language “MySQL”, and my tutorial is “TRIGGER IN MYSQL”.. you will know ?? let’s do read this article, have fun and enjoy friends to read…

1. Trigger

Previously you known trigger in Mysql ?. Trigger in mysql  query in MySQL used for calling one command or more than one command in SQL automatically after process update, insert, or delete from the table.

This is usefulness of the trigger :

  • The trigger we can update the data automatically if we want to change the contents of the table.
  • And the second trigger function can also be used to implement a system log, and it will automatically save to the table
  • We can also use the trigger if you want the validation and verification of data before the data is stored in tables.


2. Making New Trigger

You can follow this command, if you will making the new trigger :

Example 1 :

CREATE TRIGGER trigger_name
[BEFORE | AFTER]  [UPDATE | DELETE | INSERT]
ON your_table_name
FOR EACH ROW statement


Explanation :

Before
>> We can determine when the process will be executed (run) "before" process

After
>> We can determine when the process will be executed (run) "after" process

Insert

>> Is to determine the event "insert" on the trigger that will run on command - a command trigger

Update
>> Is to determine the event "Update" on the trigger that will run on command - a command trigger

Delete
>> Is to determine the event "delete" on the trigger that will run on command - a command trigger


3. Deleting Trigger

Because we can create a trigger, we also prepare Mysql command to remove the trigger, and this syntax to remove the trigger

DROP TRIGGER trigger_name. your_table_name;



Ok… just it…
I hope  you understand..
Thank you for visiting…
See you later friends

Friday, September 28, 2012

ADD, DELETE, REPLACE ACCESS RIGHTS IN MYSQL


Hello my friends.. you are on my blog at “We Are Knowledge”…  In here you will getting and take many IT knowledge likely : Mysql, Php, Cobol, Visual Basic 6, and other Program language..

Likely this article to fill IT knowledge, because now, I want giving you tutorial program language MYSQL again, but with different material.. And this is the tutorial :

1. Add and manage user access rights
2. Removing User Access Rightsc and
3. Changing the User Password

You will know all ? let’s do read this article… have fun friend to read my article…


1. Add and manage user access rights

We can also add and set permissions contained in MYSQL programming language .. To add we usually do the command "insert" in the database we have created. Or we can also use the command "grant" and "revoke".

These are a few examples to add permissions :

Example 1 :

GRANT USAGE ON  *.* TO wak@localhost
IDENTIFIED BY ‘knowledge’;

Example 2 :

GRANT ALL PRIVILEGES ON havefun.* TO wak@localhost
IDENTIFIED BY ‘knowledge’ WITH GRANT OPTION;

Example 3 :

GRANT ALL PRIVILEGES ON *.* TO wak@localhost
IDENTIFIED BY ‘knowledge’ WITH GRANT OPTION;


These are a few examples to set permissions :

Example 4 :

GRANT CREATE ON weare.* TO knowledge;
FLUSH PRIVILAGES;

Example 5 :

GRANT ALL PROVILAGES ON weare.* TO knowledge;
FLUSH PRIVILAGES;


2. Removing User Access Rightsc

We can also remove user permissions on the database we have created at MYSQL. we can use the command "REVOKE" to delete user permissions on the database.

These are a few examples to remove permissions :

Example 6 :

REVOKE CREATE ON weare.* FROM knowledge;
FLUSH PROVOLAGES;


3. Changing the User Password

And now we have entered the final discussion, the change password that we created earlier. We can make use of the "update". Since the "update" is the command to change the data that we created earlier in MYSQL, without having to remove up first.

Example 7 :

UPDATE weare SET password = PASSWORD(‘3626’) WHERE
User = ‘admin’ AND host = ‘localhost’;

Example 8 :

SET PASSWORD FOR admin@localhost = “ PASSWORD (‘3226’);
FLUSH PRIVILEGES;



Ok just for it..
I hope you understand..
See you laters..

Thursday, September 27, 2012

GRANT AND REVOKE IN MYSQL



Hi.. Welcome to my blog at “We Are Knowledge”. This blog to fill many IT knowledge.. You can find it. In here to be found IT knowledge from desktop programming until web programming. So let’s do read my article, you can getting or taken FREE..


What do you find ?? About MYSQL ?? If yes.. you was choice the right blog.. because now, I want giving you tutorial about it, and discuss of “GRANT AND REVOKE IN MYSQL”. You know that ?? previously you was ever reading.. ?? If you never reading, so let’s do read my article… have fun and enjoy to read this article friends..


Is a tutorial on setting permissions in MYSQL programming language. And for a time, I would dispose of "REVOKE and GRANT" to set it.


      1. GRANT

Grant in program language MYSQL is Grant is an order that has been provided by the programming language MYSQL to give (make) the right of access permissions for the user (client) in order to access MySQL databases, tables and columns like (insert, update, delete). In addition to the functions at the behest of Grant can also add a new user with this command.

This is a common form using the GRANT command :

GRANT priv_type
ON {table_name | * | *.* | db_name. *}
TO user_name [IDENTIFIED BY ‘your_password’]
[WITH GRANT OPTION]


      2. REVOKE

REVOKE command in MYSQL programming language which is a command to delete or revoke the MySQL user permissions are previously been granted (using GRANT)

This is a common form using the REVOKE command :

REVOKE priv_type
ON {table_name | * | *.* | db_name. *}
FROM your_user_name



      3. OPTION OF PRIV_TYPE
You can choice one for change “prive_type” :
           

 
ALL PRIVILEGES
ALTER
CREATE
DELETE
DROP
FILE
DELETE
INSERT
PROCESS
REFERENCES
RELOAD
SELECT
SHUTDOWN
UPDATE
USAGE
 
Ok.. just it…
I hope you like this
See you later friends…