Skip to main content

Posts

Showing posts with the label MySQL
World Nomads Logo

How do I run Delete query from MySQL?

MySQL DELETE Statement- MySQL DELETE statement is used to delete data from the MySQL table within the database. By using delete statement, we can delete records on the basis of conditions. Syntax: DELETE FROM table_name WHERE (Condition specified); Example: DELETE FROM cus_tbl WHERE cus_id = 6; Subscribe channel on YouTube:- https://www.youtube.com/c/ipctrd/videos Read this post on Blogger:- http://ipctrd.blogspot.in/ Like page on Facebook:- https://www.facebook.com/ipctrd/ Tweet about video on twitter:- https://twitter.com/ipctrd See you at Instagram :- https://www.instagram.com/ipctrd/ Google+ :- https://plus.google.com/u/0/101013097390807587448

How do I fier update query in MySQL?

MySQL UPDATE statement is used to update data of the MySQL table within the database. It is used when you need to modify the table. Syntax: Following is a generic syntax of UPDATE command to modify data into the MySQL table: UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause] Note: One or more field can be updated altogether. Any condition can be specified by using WHERE clause. You can update values in a single table at a time. WHERE clause is used to update selected rows in a table. Example: Here, we have a table "cus_tbl" within the database "customers". We are going to update the data within the table "cus_tbl". This query will update cus_surname field for a record having cus_id as 5. UPDATE cus_tbl SET cus_surname = 'Ambani' WHERE cus_id = 5; Subscribe channel on YouTube:- https://www.youtube.com/c/ipctrd/videos Read this post on Blogger:- http://ipctrd.blogspot.in/ Like page on Facebook:- htt...

How to insert data in partial fields in a table of MySQL? Happy New Year 2018!

MySQL INSERT DotColor - Color by Number - Peishu Su Example 2: for partial fields In such case, it is mandatory to specify field names. INSERT INTO emp(id,name) VALUES (7, 'Sonoo');    Example 3: inserting multiple records Here, we are going to insert record in the "cus_tbl" table of "customers" database. INSERT INTO cus_tbl (cus_id, cus_firstname, cus_surname) VALUES (5, 'Ajeet', 'Maurya'),  (6, 'Deepika', 'Chopra'), (7, 'Vimal', 'Jaiswal'); Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  whatsapp See you at  Instagram Google +

How to INSERT data into table in MYSQL?

MySQL INSERT MySQL INSERT statement is used to insert data in MySQL table within the database. We can insert single or multiple records using a single query in MySQL. Syntax: The SQL INSERT INTO command is used to insert data in MySQL table. Following is a generic syntax: INSERT INTO table_name ( field1, field2,...fieldN )   VALUES   ( value1, value2,...valueN );   Field name is optional. If you want to specify partial values, field name is mandatory. Syntax for all fields: INSERT INTO table_name VALUES ( value1, value2,...valueN );   Example 1: for all fields If you have to store all the field values, either specify all field name or don't specify any field. Example: INSERT INTO emp VALUES (7, 'Sonoo' , 40000);   Or, INSERT INTO emp(id, name ,salary) VALUES (7, 'Sonoo' , 40000);   Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  wha...

What is MySQL Queries and how do we use them?

MySQL Queries:- A list of commonly used MySQL queries to create database, use database, create table, insert record, update record, delete record, select record, truncate table and drop table are given below. 1) MySQL Create Database MySQL create database is used to create database. For example create database db1;  2) MySQL Select/Use Database MySQL use database is used to select database. For example use db1;  Ipctrd Inc. 3) MySQL Create Query MySQL create query is used to create a table, view, procedure and function. For example: CREATE TABLE customers    (id int(10),     name varchar(50),     city varchar(50),   PRIMARY KEY (id )    );    4) MySQL Alter Query MySQL alter query is used to add, modify, delete or drop colums of a table. Let's see a query to add column in customers table: ALTER TABLE customers  ADD age varchar(50);    5) MySQL Insert Query MySQL ins...

How to drop VIEW in MySQL ?

MySQL Drop VIEW You can drop the VIEW by using the DROP VIEW statement. Syntax: DROP VIEW [IF EXISTS] view_name;  Parameters: view_name: It specifies the name of the VIEW that you want to drop. IF EXISTS: It is optional. If you do not specify this clause and the VIEW doesn't exist, the DROP VIEW statement will return an error. Example: DROP VIEW trainer; To see the dropped VIEW(It will never found): Syntax: SELECT * FROM view_name;  Return empty*** Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  whatsapp See you at  Instagram

How to update view in MySQL ?

MySQL Update VIEW In MYSQL, the ALTER VIEW statement is used to modify or update the already created VIEW without dropping it. Syntax: ALTER VIEW view_name AS  SELECT columns  FROM table  WHERE conditions;  Example: The following example will alter the already created VIEW name "trainer" by adding a new column. ALTER VIEW trainer AS  SELECT course_name, course_trainer, course_id  FROM courses;  To see the altered VIEW: SELECT*FROM trainer; Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  whatsapp See you at  Instagram

How to create VIEW in MySQL?

MySQL Create VIEW A VIEW is created by SELECT statements. SELECT statements are used to take data from the source table to make a VIEW. Syntax: CREATE [OR REPLACE] VIEW view_name AS  SELECT columns  FROM tables  [WHERE conditions];  Parameters: OR REPLACE: It is optional. It is used when a VIEW already exist. If you do not specify this clause and the VIEW already exists, the CREATE VIEW statement will return an error. view_name: It specifies the name of the VIEW that you want to create in MySQL. WHERE conditions: It is also optional. It specifies the conditions that must be met for the records to be included in the VIEW. The following example will create a VIEW name "trainer". This is a virtual table made by taking data from the table "courses". CREATE VIEW trainer AS  SELECT course_name, course_trainer   FROM courses;  To see the created VIEW: Syntax: SELECT * FROM view_name;  Let's see how it looks the created VIEW: S...

How to TRUNCATE table in MySQL?

MYSQL TRUNCATE statement removes the complete data without removing its structure. The TRUNCATE TABLE statement is used when you want to delete the complete data from a table without removing the table structure. Syntax: TRUNCATE TABLE  table_name; Example: This example specifies how to truncate a table. In this example, we truncate the table "cus_tbl". TRUNCATE TABLE  cus_tbl; See the table: SELECT* FROM cus_tbl; MySQL DROP Table MYSQL DROP table statement removes the complete data with structure. Syntax: DROP TABLE  table_name; Example: This example specifies how to drop a table. In this example, we are dropping the table "cus_tbl". DROP TABLE  cus_tbl; MySQL TRUNCATE Table vs DROP Table:- You can also use DROP TABLE command to delete complete table but it will remove complete table data and structure both. You need to re-create the table again if you have to store some data. But in the case of TRUNCATE TABLE, it removes only table data not st...

How to RENAME column and table itself in MySQL?

5) RENAME column in table Syntax: ALTER TABLE table_name CHANGE COLUMN old_name new_name  column_definition [ FIRST | AFTER column_name ] Example: In this example, we will change the column name "cus_surname" to "cus_title". Use the following query to do this:  ALTER TABLE  cus_tbl CHANGE COLUMN cus_surname cus_title varchar(20) NOT NULL; 6) RENAME table Syntax: ALTER TABLE table_name RENAME TO new_table_name; Example: In this example, the table name cus_tbl is renamed as cus_table. ALTER TABLE cus_tbl RENAME TO cus_table; Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  whatsapp See you at  Instagram Google +

How to Modify column definition in MySQL?

3) MODIFY column in the table The MODIFY command is used to change the column definition of the table. Syntax: ALTER TABLE table_name  MODIFY column_name column_definition  [ FIRST | AFTER column_name ];  Example: In this example, we modify the column cus_surname to be a data type of varchar(50) and force the column to allow NULL values. Use the following query to do this: ALTER TABLE cus_tbl  MODIFY cus_surname varchar(50) NULL;  4) DROP column in table Syntax: ALTER TABLE table_name  DROP COLUMN column_name;  Let's take an example to drop the column name "cus_address" from the table "cus_tbl". Use the following query to do this: ALTER TABLE cus_tbl  DROP COLUMN cus_address; Continue... Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  whatsapp See you at  Instagram Google +

How to Add multiple column using Alter table in MySQl?

MySQL ALTER Table MySQL ALTER statement is used when you want to change the name of your table or any table field. It is also used to add or delete an existing column in a table. The ALTER statement is always used with " ADD ", " DROP " and " MODIFY " commands according to the situation. 1) ADD a column in the table Syntax: ALTER TABLE table_name   ADD new_column_name column_definition   [ FIRST | AFTER column_name ];   Parameters table_name: It specifies the name of the table that you want to modify. new_column_name: It specifies the name of the new column that you want to add to the table. column_definition: It specifies the data type and definition of the column (NULL or NOT NULL, etc). FIRST | AFTER column_name: It is optional. It tells MySQL where in the table to create the column. If this parameter is not specified, the new column will be added to the end of the table. Example: In this example, we add a new column "cus_age" in the existing...

How to create table in MySQL?

MySQL CREATE TABLE The MySQL CREATE TABLE command is used to create a new table into the database. A table creation command requires three things: Name of the table Names of fields Definitions for each field Syntax: Following is a generic syntax for creating a MySQL table in the database. CREATE TABLE table_name (column_name column_type...);  Example: Here, we will create a table named "cus_tbl" in the database "customers". CREATE TABLE cus_tbl(     cus_id INT NOT NULL AUTO_INCREMENT,     cus_firstname VARCHAR(100) NOT NULL,     cus_surname VARCHAR(100) NOT NULL,     PRIMARY KEY ( cus_id )  );  See the created table: Use the following command to see the table already created: SHOW tables;    To see the table structure: DESCRIBE cus_tbl; Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter...

How to Select Database for use and Drop Database in MySQL?

How to create Database in MySQL?

How to select to use & drop DB in MySQL

MySQL SELECT Database SELECT Database is used in MySQL to select a particular database to work with. This query is used when multiple databases are available with MySQL Server. You can use SQL command USE to select a particular database. Syntax: USE database_name; Example: Let's take an example to use a database name "customers". USE customers; MySQL Drop Database You can drop/delete/remove a MySQL database easily with the MySQL command. You should be careful while deleting any database because you will lose your all the data available in your database. Syntax: DROP DATABASE database_name; Example: Let's take an example to drop a database name "employees" Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  whatsapp See you at  Instagram Google +

How to create Database?

MySQL Create Database You can create a MySQL database by using MySQL Command Line Client. Open the MySQL console and write down password, if you set one while installation. Now you are ready to create database. Syntax: CREATE DATABASE database_name;  Example: Let's take an example to create a database name "employees" CREATE DATABASE employees;  You can check the created database by the following query: SHOW DATABASES;  By this, you can see the all created databases. Subscribe channel on  YouTube Read this post on  Blogger Like page on  Facebook Tweet about video on  twitter Let's chat on  whatsapp See you at  Instagram Google +

What is MySQL?

What is MySQL? MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by Oracle Corporation. MySQL is a database management system. A database is a structured collection of data. It may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL Server. Since computers are very good at handling large amounts of data, database management systems play a central role in computing, as standalone utilities, or as parts of other applications. MySQL databases are relational. A relational database stores data in separate tables rather than putting all the data in one big storeroom. The database structures are organized into physical files optimized for speed. The logical model, with objects such as databases, tables, views, rows, and columns, offers a flexi...

Contact Us

Name

Email *

Message *