MySQL Articles

Page 73 of 355

How can we use MySQL SELECT without FROM clause?

Sravani S
Sravani S
Updated on 22-Jun-2020 2K+ Views

FROM clause after SELECT shows the references to a table. But if there is no reference to any table then we can use SELECT without the FROM clause. In other words, we can say that SELECT can be used to retrieve rows computed without reference to any table. Consider the following statements −mysql> Select concat_ws(" ","Hello", "World"); +---------------------------------+ | concat_ws(" ","Hello", "World") | +---------------------------------+ | Hello World | +---------------------------------+ 1 row in set (0.00 sec) mysql> Set @var1=100; Query OK, 0 rows affected (0.00 sec) mysql> Select @var1; +-------+ | @var1 | +-------+ | 100 | +-------+ 1 row in set (0.00 sec)

Read More

How can I get the output of multiple MySQL tables from a single query?

Vrundesha Joshi
Vrundesha Joshi
Updated on 22-Jun-2020 425 Views

As we know that a query can have multiple MySQL statements followed by a semicolon. Suppose if we want to get the result from multiple tables then consider the following example to get the result set from ‘Student_info’ and ‘Student_detail’ by writing a single query −mysql> Select Name, Address from Student_info; Select Studentid, Address from Student_detail; +---------+------------+ | Name    | Address    | +---------+------------+ | YashPal | Amritsar   | | Gaurav  | Chandigarh | | Raman   | Shimla     | | Ram     | Jhansi     | | Shyam   | Chandigarh | | ...

Read More

What is the use of 'c' option while writing MySQL statements?

Ramu Prasad
Ramu Prasad
Updated on 22-Jun-2020 590 Views

‘\c’ option means ‘clear’ and is used to clear the current input. Suppose if we do not want to execute a command that we are entering, then we can use a clear \c option which clears the current input. For example, the use of \c option can be done as follows −mysql> Select * -> from\cIn the example above, when we use \c in a statement, MySQL clears the current input and returns back to the MySQL prompt for accepting other statements.

Read More

What would be the result if we perform any kind of arithmetic calculations in MySQL having one of the arguments as NULL?

radhakrishna
radhakrishna
Updated on 22-Jun-2020 165 Views

MySQL always throws NULL as the result of arithmetic calculations in which one of the arguments is NULL. Consider the following example having NULL as an argument with addition, subtraction, multiplication, and division −mysql> Select 10*NULL; +---------+ | 10*NULL | +---------+ |    NULL | +---------+ 1 row in set (0.12 sec) mysql> Select 10+NULL; +---------+ | 10+NULL | +---------+ | NULL | +---------+ 1 row in set (0.00 sec) mysql> Select 10-NULL; +---------+ | 10-NULL | +---------+ |    NULL | +---------+ 1 row in set (0.07 sec) mysql> Select 10/NULL; +---------+ | 10/NULL | +---------+ ...

Read More

Why in MySQL, we cannot use arithmetic operators like '=', '<' or '<>' with NULL?

vanithasree
vanithasree
Updated on 22-Jun-2020 257 Views

The reason behind it is that we will not receive any meaningful results from the comparisons when we use NULL with the comparison operators like ‘=’, ‘ Select 10 = NULL, 10< NULL, 10NULL; +-----------+----------+----------+ | 10 = NULL | 10< NULL | 10NULL | +-----------+----------+----------+ |      NULL |     NULL |     NULL | +-----------+----------+----------+ 1 row in set (0.07 sec)The above result set is not meaningful in any sense.

Read More

What will happen to MySQL current transaction, if in the middle of that transaction, the DDL statement is executed?

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 380 Views

The current MySQL transaction will be committed and ended when any of the DDL statement such as CREATE or DROP databases, Create, ALTER or DROP tables or stored routines is executed in the middle of the current transaction. All the database changes made in the current transaction will be made permanent and cannot be rolled back.Examplemysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO MARKS Values(6, 'Manak', 'History', 70); Query OK, 1 row affected (0.26 sec) mysql> Create table student(id int, Name Varchar(10), ); Query OK, 0 rows affected (0.84 sec)As we can see ...

Read More

Instead of using a semicolon (;) terminator symbol, is there any other built-in-commands which execute the MySQL query?

V Jyothi
V Jyothi
Updated on 22-Jun-2020 1K+ Views

With the help of the following built-in commands, MySQL can execute a query even if semicolon (;) terminator symbol is not used.egoWe can use this command by using \G option. It means to send the current statement to the server to be executed and display the result in vertical format. When we use \G and omitting semicolon(;) in a statement (single or multiple lines), MySQL determines the end of the statement as and when it encounters \G. Consider the example below −mysql> Select * from ratelist\G *************************** 1. row *************************** Sr: 1 Item: A Price: 502 ...

Read More

How can a user implicitly end current MySQL transaction?

George John
George John
Updated on 22-Jun-2020 238 Views

Following are the ways with the help of which current MySQL transaction can be ended implicitly −By Running DDL statementThe current MySQL transaction will end implicitly and changes will be committed by running any of the DDL statement such as CREATE or DROP databases, Create, ALTER or DROP tables or stored routines. It is because, in MySQL, these statements cannot be rolled back.Examplemysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO MARKS Values(3, 'gaurav', 'Comp', 69); Query OK, 1 row affected (0.26 sec) mysql> Create table student(id int, Name Varchar(10), ); Query OK, 0 ...

Read More

How changes, made in the current transaction, can be permanently recordednin MySQL database?

Rama Giri
Rama Giri
Updated on 22-Jun-2020 367 Views

We can use COMMIT command to make the changes, made in a current transaction, permanently recorded in MySQL database. Suppose if we run some DML statements and it updates some data objects, then COMMIT command will record these updates permanently in the database.Examplemysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO Marks Values(1, 'Aarav', 'Maths', 50); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO Marks Values(2, 'Harshit', 'Maths', 55); Query OK, 1 row affected (0.00 sec) mysql> COMMIT; Query OK, 0 rows affected (0.06 sec)In this example, the COMMIT statement will ...

Read More

What happens if I use both G and semicolon (;) termination symbol with a single MySQL statement?

Giri Raju
Giri Raju
Updated on 22-Jun-2020 536 Views

As we know that \G option sends the command to MySQL server for execution and with the help of Semicolon (;) MySQL determines the end of the statement. It is also known that both of them have a different format of the result set.Now, if we will use both of those in MySQL statement then the output would be produced on the basis that which of them is encountered first by MySQL. For others, MySQL will produce an error. It can be understood with the help of the following example −mysql> Select CURDATE();\G +------------+ | CURDATE()  | +------------+ | 2017-11-06 ...

Read More
Showing 721–730 of 3,547 articles
« Prev 1 71 72 73 74 75 355 Next »
Advertisements