Found 4219 Articles for MySQLi

What MySQL returns on using any other character than ‘T’ or ‘Space’ between date and time parts?

usharani
Updated on 29-Jan-2020 06:48:45

44 Views

In that case, MySQL will return all zeros at the place of time along with correct date part. An example is as follows in which we used character ‘W’ at the place of ‘T’ or ‘Space’ between date and time part −mysql> Select TIMESTAMP('2017-10-20W06:10:36'); +----------------------------------+ | TIMESTAMP('2017-10-20W06:10:36') | +----------------------------------+ | 2017-10-20 00:00:00              | +----------------------------------+ 1 row in set, 1 warning (0.00 sec)

How can I use any character, at the place of space, in MySQL TIMESTAMP to distinguish between date and time parts?

varun
Updated on 29-Jan-2020 06:49:22

81 Views

We can use the only character ‘T’ (in Capital form only) at the place of space between date and time part. It can be elucidated with the help of the following example −mysql> Select TIMESTAMP('2017-10-20T06:10:36'); +----------------------------------+ | TIMESTAMP('2017-10-20T06:10:36') | +----------------------------------+ | 2017-10-20 06:10:36              | +----------------------------------+ 1 row in set (0.00 sec)

Which punctuation character can be used as the delimiter between MySQL time parts?

Krantik Chavan
Updated on 29-Jan-2020 06:50:19

57 Views

As in the case of date values, MySQL also permits us to use a relaxed format for time. We can use any punctuation character between time parts as a delimiter. Some examples are as follows −mysql> Select timestamp('2017-10-20 04+05+36'); +----------------------------------+ | timestamp('2017-10-20 04+05+36') | +----------------------------------+ | 2017-10-20 04:05:36              | +----------------------------------+ 1 row in set (0.00 sec) mysql> Select timestamp('2017-10-20 04*05*36'); +----------------------------------+ | timestamp('2017-10-20 04*05*36') | +----------------------------------+ | 2017-10-20 04:05:36              | +----------------------------------+ 1 row in set (0.00 sec) mysql> Select timestamp('2017-10&20 04@05+36'); +----------------------------------+ | timestamp('2017-10&20 ... Read More

Which punctuation character can be used as the delimiter between MySQL date parts?

Prabhas
Updated on 29-Jan-2020 06:51:13

47 Views

In this matter, MySQL permits us to use a relaxed format to date. We can use any punctuation character between date parts as a delimiter. Some examples are as follows −mysql> Select date ('2016/10/20'); +---------------------+ | date ('2016/10/20') | +---------------------+ | 2016-10-20          | +---------------------+ 1 row in set (0.00 sec) mysql> Select date('2016^10^20'); +--------------------+ | date('2016^10^20') | +--------------------+ | 2016-10-20         | +--------------------+ 1 row in set (0.00 sec) mysql> Select date ('2016@10@20'); +---------------------+ | date ('2016@10@20') | +---------------------+ | 2016-10-20          | +---------------------+ 1 row in set (0.00 sec) mysql> Select date ('2016+10+20'); +---------------------+ | date ('2016+10+20') | +---------------------+ | 2016-10-20          | +---------------------+ 1 row in set (0.00 sec)

How can we fetch a particular row as output from a MySQL table?

Ayyan
Updated on 20-Jun-2020 06:20:28

2K+ Views

For fetching a particular row as output, we need to use WHERE clause in the SELECT statement. It is because MySQL returns the row based on the condition parameter given by us after WHERE clause.ExampleSuppose we want to fetch a row which contains the name ‘Aarav’ from student table then it can be done with the help of the following query −mysql> Select * from Student WHERE Name = 'Aarav'; +------+-------+---------+---------+ | Id   | Name  | Address | Subject | +------+-------+---------+---------+ | 2    | Aarav | Mumbai  | History | +------+-------+---------+---------+ 1 row in set (0.00 sec)

How can we fetch one or more columns as output from a MySQL table?

Ankith Reddy
Updated on 29-Jan-2020 06:33:57

184 Views

The SELECT command can be used to fetch one or more columns as output from MySQL table. An  example is given below to fetch one or more columnsmysql> Select * from Student; +------+---------+---------+-----------+ | Id   | Name    | Address | Subject   | +------+---------+---------+-----------+ | 1    | Gaurav  | Delhi   | Computers | | 2    | Aarav   | Mumbai  | History   | | 15   | Harshit | Delhi   | Commerce  | | 17   | Raman   | Shimla  | Computers | +------+---------+---------+-----------+ 4 rows in set (0.01 sec) ... Read More

In the query [SELECT column1, column2 FROM table_name WHERE condition; ] which clause among ‘SELECT’, ‘WHERE’ and ‘FROM’ is evaluated in the last by the database server and why?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

357 Views

As we know that SELECT clause is used to show all the rows and columns hence SELECT clause is evaluated in the last by the database server.

How can it be possible to add 3 months interval in a MySQL date without using the word ‘Months’ with interval?

Nishtha Thakur
Updated on 29-Jan-2020 06:35:05

277 Views

It is possible with the help of keyword Quarter as follows −mysql> Select '2017-06-20' + INTERVAL 1 Quarter AS 'After 3 Months Interval'; +-------------------------+ | After 3 Months Interval | +-------------------------+ | 2017-09-20              | +-------------------------+ 1 row in set (0.00 sec)

What are the different ways in MySQL to add ‘half year interval’ in date?

seetha
Updated on 29-Jan-2020 06:36:20

411 Views

We can add ‘half year interval’ in date ith the following ways −(A) By adding interval of 6 Monthsmysql> Select '2017-06-20' + INTERVAL 6 Month AS 'After Half Year Interval'; +--------------------------+ | After Half Year Interval | +--------------------------+ |  2017-12-20              | +--------------------------+ 1 row in set (0.00 sec)(B) By adding interval of 2 quartersmysql> Select '2017-06-20' + INTERVAL 2 Quarter AS 'After Half Year Interval'; +--------------------------+ | After Half Year Interval | +--------------------------+ | 2017-12-20               | +--------------------------+ 1 row in set (0.00 sec)Above query will add half year interval in date with the help of Quarter keyword.

How can we fetch all the records from a particular MySQL table?

Alankritha Ammu
Updated on 29-Jan-2020 06:37:09

190 Views

We can fetch all the record from a MySQL table by using SELECT * from table_name; query. An example is as follows, fetched all the records from ‘Employee’ table −mysql> Select * from Employee; +------+--------+ | Id   | Name   | +------+--------+ | 100  | Ram    | | 200  | Gaurav | | 300  | Mohan  | +------+--------+ 3 rows in set (0.00 sec)

Advertisements