Found 6705 Articles for Database

What are the synonym statements of MySQL DESCRIBE?

vanithasree
Updated on 22-Jun-2020 08:37:27

310 Views

Followings are the synonyms statements of MySQL DESCRIBE i.e. the statements with the help of which we can get the same kind of information/structure of the table as we get from DESCRIBE −EXPLAIN StatementEXPLAIN is the synonym of the DESCRIBE statement. Its syntax is also similar to the DESCRIBE statement. Consider the following example −mysql> Explain Employee; +-------+-------------+------+-----+---------+------------------+ | Field | Type        | Null | Key | Default | Extra            | +-------+-------------+------+-----+---------+------------------+ | ID    | int(11)     | NO   | PRI | NULL    | auto_increment   | | ... Read More

How can we use a MySQL subquery with FROM clause?

Arushi
Updated on 22-Jun-2020 08:38:19

277 Views

Subqueries can work well in a SELECT statement FROM clause. Following is the syntax for the same −SELECT … FROM(subquery) [AS] name …To make it understand we are using the following data from table ‘cars’ −mysql> Select * from Cars; +------+--------------+---------+ | ID   | Name         | Price   | +------+--------------+---------+ | 1    | Nexa         | 750000  | | 2    | Maruti Swift | 450000  | | 3    | BMW          | 4450000 | | 4    | VOLVO        | 2250000 | | ... Read More

How can we use a subquery that contains a reference to a table that also appears in the outer query?

Alankritha Ammu
Updated on 22-Jun-2020 08:24:37

791 Views

A subquery that contains a reference to a table that also appears in the outer query is called a correlated subquery. In this case,  MySQL evaluates from inner query to the outer query. To understand it we are having the following data from table ‘cars’ −mysql> Select * from Cars; +------+--------------+---------+ | ID   | Name         | Price   | +------+--------------+---------+ | 1    | Nexa         | 750000  | | 2    | Maruti Swift | 450000  | | 3    | BMW          | 4450000 | | 4 ... Read More

What is the use of comparison operators with MySQL subquery?

Ankith Reddy
Updated on 22-Jun-2020 08:25:03

197 Views

The subquery can return at most one value. The value can be the result of an arithmetic expression or a column function. MySQL then compares the value that results from the subquery with the value on the other side of the comparison operator. MySQL subquery can be used before or after any of the comparison operators like =, >, >=,

How can I get the information about a particular column of a table by MySQL DESCRIBE statement?

radhakrishna
Updated on 22-Jun-2020 08:18:32

1K+ Views

As we know that DESCRIBE statement will provide the information/structure of the whole table. With the help of DESCRIBE statement along with table name and the column name, we can get the information about that column.SyntaxDESCRIBE table_name col_name;Example1mysql> Describe employee ID; +-------+---------+------+-----+---------+----------------+ | Field | Type    | Null | Key | Default | Extra          | +-------+---------+------+-----+---------+----------------+ | ID    | int(11) | NO   | PRI | NULL    | auto_increment | +-------+---------+------+-----+---------+----------------+ 1 row in set (0.11 sec)The query above will give the information about the column ‘ID’ of a table named ‘employee’.Example2mysql> Describe ... Read More

What kind of information is displayed by MySQL DESCRIBE statement?

mkotla
Updated on 22-Jun-2020 08:26:00

89 Views

The DESCRIBE statement gives information about MySQL table’s structure.ExampleConsider the constructing of the following table name ‘Employee’ with Create Table statement as follows −mysql> Create table Employee(ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Name Varchar(20)); Query OK, 0 rows affected (0.20 sec)Now with the help of ‘DESCRIBE Employee‘ statement, we can get the information about the employee table.mysql> Describe Employee; +-------+-------------+------+-----+---------+------------------+ | Field | Type        | Null | Key | Default | Extra            | +-------+-------------+------+-----+---------+------------------+ | ID    | int(11)     | NO   | PRI | NULL    | auto_increment ... Read More

What is the default sort order in MySQL tables?

Rishi Rathor
Updated on 22-Jun-2020 08:23:55

694 Views

The default sort order in MySQL tables is ascending. Whenever we use ORDER BY clause to sort out the rows of a table, MySQL gives output in ascending order, with the smallest value first. Consider the following example from a table named ‘student’ −mysql> Select * from student order by name; +--------+--------+--------+ | Name   | RollNo | Grade  | +--------+--------+--------+ | Aarav  | 150    | M.SC   | | Aryan  | 165    | M.tech | | Gaurav | 100    | B.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)We can see the query above gives the output, ordered by name, in ascending order, start with smallest value ‘Name’ column.

How can we use a MySQL subquery with INSERT statement?

Arjun Thakur
Updated on 22-Jun-2020 08:09:02

899 Views

It can be understood with the help of an example in which we would copy the values of a table into other table. We are using the data from table ‘cars’ and copy its data to table ‘copy_cars’ −mysql> CREATE TABLE copy_cars LIKE cars; Query OK, 0 rows affected (0.86 sec) mysql> SELECT * from copy_cars; Empty set (0.08 sec)The following query using the subquery will insert the values same as ‘cars’ to table ‘copy_cars’ −mysql> INSERT INTO Copy_cars Select * from Cars; Query OK, 8 rows affected (0.07 sec) mysql> SELECT * from copy_cars; +------+--------------+---------+ | ID ... Read More

How can the rows be sorted out in a meaningful way?

Abhinanda Shri
Updated on 22-Jun-2020 08:23:17

75 Views

For sorting the rows in a meaningful way we can use ORDER BY clause. Suppose we want to sort the rows of the following table −mysql> Select * from Student; +--------+--------+--------+ | Name   | RollNo | Grade  | +--------+--------+--------+ | Gaurav |    100 | B.tech | | Aarav  |    150 | M.SC   | | Aryan  |    165 | M.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)The query below sorted the table by ‘Name’.mysql> Select * from student order by name; +--------+--------+--------+ | Name   | RollNo | Grade  | +--------+--------+--------+ | Aarav  |   ... Read More

How can we combine ROW selection with COLUMN selection in MySQL?

Nancy Den
Updated on 22-Jun-2020 08:27:42

189 Views

For combining ROW selection with COLUMN selection, we can use the ‘WHERE’ clause. For example, we have a table below −mysql> Select * from Student; +--------+--------+--------+ | Name   | RollNo | Grade  | +--------+--------+--------+ | Gaurav | 100    | B.tech | | Aarav  | 150    | M.SC   | | Aryan  | 165    | M.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)Now, the following query will show how we can combine ROW selection with COLUMN selection using WHERE clause.mysql> Select Name, RollNo, Grade from Student where Grade='M.Sc' or Grade='B.Tech'; +--------+--------+--------+ | Name   | RollNo ... Read More

Advertisements