Articles on Trending Technologies

Technical articles with clear explanations and examples

How to get the first day of next month in MySQL?

V Jyothi
V Jyothi
Updated on 29-Jan-2020 1K+ Views

With the help of following MySQL query, we can get the first day of next month −mysql> SELECT DATE_FORMAT(CURDATE() + INTERVAL 1 MONTH,'%Y-%m-01') AS 'FIRST DAY OF NEXT MONTH'; +-------------------------+ | FIRST DAY OF NEXT MONTH | +-------------------------+ | 2017-11-01              | +-------------------------+ 1 row in set (0.00 sec)

Read More

How can we create a new MySQL table by selecting specific column/s from another existing table?

karthikeya Boyini
karthikeya Boyini
Updated on 29-Jan-2020 304 Views

As we know that we can copy the data and structure from an existing table by CTAS script. If we want to select some specific column/s from another table then we need to mention them after SELECT. Consider the following example in which we have created a table named EMP_BACKUP1 by selecting a specific column ‘name’ from already existing table ‘Employee’ −mysql> Create table EMP_BACKUP1 AS Select name from employee; Query OK, 3 rows affected (0.25 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> Select * from EMP_BACKUP1; +--------+ | name   | +--------+ | Ram    | | ...

Read More

How can we copy data with some condition/s from existing MySQL table?

Sai Nath
Sai Nath
Updated on 29-Jan-2020 322 Views

As we know that we can copy the data and structure from an existing table by CTAS script. If we want to copy data with some condition/s then we need to use WHERE clause with CTAS script. Consider the example below −mysql> Create table EMP_BACKUP2 AS SELECT * from EMPLOYEE WHERE id = 300 AND Name = 'Mohan'; Query OK, 1 row affected (0.14 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> Select * from EMP_BACKUP2; +------+-------+ | Id   | Name  | +------+-------+ | 300  | Mohan | +------+-------+ 1 row in set (0.00 sec)In the example ...

Read More

How can we get a list of columns in an existing MySQL table?

Arjun Thakur
Arjun Thakur
Updated on 29-Jan-2020 364 Views

Suppose if we forgot the names of the columns in an existing table then we can use SHOW COLUMNS statement as follows to get the list of columns −mysql> SHOW COLUMNS from Employee\G *************************** 1. row ***************************   Field: Id    Type: int(11)    Null: YES     Key: Default: NULL   Extra: *************************** 2. row ***************************   Field: Name    Type: varchar(20)    Null: YES     Key: Default: NULL   Extra: 2 rows in set (0.07 sec)In the example above, we got the list of columns of ‘Employee’ table with the help of SHOW COLUMNS statement.

Read More

How to get last day of the next month in MySQL?

Ramu Prasad
Ramu Prasad
Updated on 29-Jan-2020 437 Views

With the help of following MySQL query, we can get the last day of next month −mysql> SELECT LAST_DAY(now() + INTERVAL 1 MONTH) AS 'LAST DAY OF NEXT MONTH'; +------------------------+ | LAST DAY OF NEXT MONTH | +------------------------+ | 2017-11-30             | +------------------------+ 1 row in set (0.00 sec)

Read More

In which format Year(2) or Year(4) MySQL will return the value of year from date '0000-00-00'?

Govinda Sai
Govinda Sai
Updated on 29-Jan-2020 218 Views

Suppose if we have stored a date value as ‘0000-00-00’ in MySQL table then on extracting year value from such kind of date, MySQL will return 0. It would not be in either Year(2) or Year(4) format. To understand it we are using the following data from ‘detail_bday’ table −mysql> Select * from detail_bday; +----+---------+------------+ | Sr | Name    | Birth_Date | +----+---------+------------+ | 1 | Saurabh  | 1990-05-12 | | 2 | Raman    | 1993-06-11 | | 3 | Gaurav   | 1984-01-17 | | 4 | Rahul    | 1993-06-11 | | 5 | Sonia   ...

Read More

Exam Guidance for CAT (Common Admission Test)

Samual Sam
Samual Sam
Updated on 28-Jan-2020 410 Views

In a world obsessed with the word ‘Management’, MBA has become one of the most sought after degrees. Management and entrepreneurship often go hand-in-hand. Most of the startup CEOs and corporate honchos are MBA degree holders. CAT which stands for Common Admission Test is a much bandied about entrance exam especially when it comes to aspirants. To make a mark for themselves and subsequently join elite institutions such as Indian Institutes of Managements, Faculty of Management Studies etc., aspirants have to score a decent percentile in CAT. With the number of students taking CAT escalating to new heights, the sense ...

Read More

Facebook introduces video as your profile pic!

Samual Sam
Samual Sam
Updated on 28-Jan-2020 324 Views

Now you can upload a 7-second video as your profile pic. Isn’t that great? You can upload a fun-filled video or just a formal introduction in just that small little profile space describing you.Along with the profile video, you can now, highlight your bio-data with a 100-character bio field.And we have an updated mobile-centric design with centered profile photos. You want more? Facebook has Big sections for photos and friends, temporary profile pics, option to pin feature photos to the top of the profile! What more can you ask for?This helps you to highlight the most important things in your ...

Read More

What do you mean by default MySQL database for the user?

Manikanth Mani
Manikanth Mani
Updated on 28-Jan-2020 336 Views

Actually, there is no default database for the user. But we have default database for the current session. It can be seen from the following query −mysql> Select Database(); +------------+ | Database() | +------------+ | sample     | +------------+ 1 row in set (0.00 sec)The above result set shows that we are using ‘sample’ database currently. It is set for the current session. We can set another database, with the help of USE statement, also for the current session as follows −mysql> USE query; Database changed mysql> Select Database(); +------------+ | Database() | +------------+ | query     ...

Read More

How can we provide a date with only year (zero months & zero days) value in MySQL?

usharani
usharani
Updated on 28-Jan-2020 293 Views

We can store a date with only year value and have zero months as well as zero-days in MySQL table by disabling NO_ZERO_IN_DATE mode. If this mode is enabled then MySQL will count such kind of date as invalid date and stores all zeros.mysql> Insert into year_testing (OrderDate) values('2017:00:00'); Query OK, 1 row affected (0.09 sec) mysql> select * from year_testing; +------------+ | OrderDate  | +------------+ | 2017-00-00 | +------------+ 1 row in set (0.00 sec) mysql> SET sql_mode = 'NO_ZERO_IN_DATE'; Query OK, 0 rows affected (0.00 sec) mysql> Insert into year_testing(OrderDate) values('2017:00:00'); Query OK, 1 row ...

Read More
Showing 55271–55280 of 61,297 articles
Advertisements