Abhinanda Shri has Published 74 Articles

Which PHP function is used to delete an existing MySQL table?

Abhinanda Shri

Abhinanda Shri

Updated on 22-Jun-2020 13:44:39

67 Views

PHP uses mysql_query function to delete an existing MySQL table. This function takes two parameters and returns TRUE on success or FALSE on failure. Its syntax is as follows −Syntaxbool mysql_query( sql, connection );Followings are the parameters used in this function −S. No.Parameter & Description1.SqlRequired - SQL query to delete an ... Read More

How can I drop an existing column from a MySQL table?

Abhinanda Shri

Abhinanda Shri

Updated on 22-Jun-2020 12:46:11

139 Views

We can delete a particular existing column from a MySQL table by using the DROP statement along with an ALTER statement. Its syntax would be as follows −SyntaxALTER TABLE table_name DROP column_name;Here,  table_name is the name of the table from which we want to delete the column.Column_name is the name ... Read More

How can we specify the number of records to be returned in MySQL output?

Abhinanda Shri

Abhinanda Shri

Updated on 22-Jun-2020 11:01:04

130 Views

We can specify the number of records to be returned in output by adding a LIMIT clause in MySQL query. LIMIT clause restricts the number of rows to be returned. Consider the following example −mysql> Select * from ratelist ORDER BY Price; +----+------+-------+ | Sr | Item | Price | ... Read More

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

Abhinanda Shri

Abhinanda Shri

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

36 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 ... Read More

How Can MySQL LOOP statement be used in a stored procedure?

Abhinanda Shri

Abhinanda Shri

Updated on 22-Jun-2020 06:39:54

372 Views

MySQL provides us a LOOP statement that executes a block of code repeatedly along with an added flexibility of using a loop label. We have the following two statements that allow us to control the loop −LEAVE statementIt allows us to exit the loop immediately without waiting for checking the ... Read More

What would be the difference between default output format when running MySQL in batch mode or interactively?

Abhinanda Shri

Abhinanda Shri

Updated on 22-Jun-2020 04:58:48

50 Views

The default MySQL output would be different if we will run the same query interactively or in batch mode. For example, if we will run the query select * from hh interactively then following would be a format of output −mysql> select * from hh; +------+ | id   | ... Read More

How can we export some field(s) from MySQL table into a text file?

Abhinanda Shri

Abhinanda Shri

Updated on 20-Jun-2020 09:23:46

594 Views

It can be done by providing the column(s) names in the SELECT … INTO OUTFILE statement while exporting the data from MySQL table into a file. We are illustrating it with the help of the following example −ExampleSuppose we are having following data from table ‘Student_info’ −mysql> Select * from ... Read More

What is the use of ALLOW_INVALID_DATES SQL mode?

Abhinanda Shri

Abhinanda Shri

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

2K+ Views

As the name suggests, enabling ALLOW_INVALID_DATES SQL mode will allow us to store invalid dates in the table. The example is given below to understand it −Examplemysql> SET sql_mode = ALLOW_INVALID_DATES; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> Insert Into detail_bday(Name, Birth_Date) values('Sonia', '1993-11-31'); Query OK, ... Read More

What are different date format characters used by MySQL DATE_FORMAT() function?

Abhinanda Shri

Abhinanda Shri

Updated on 20-Jun-2020 05:58:00

148 Views

Different date format characters used by MySQL DATE_FORMAT() function are as follows −Date Format CharacterMeaning %aIt is used to abbreviate the names of the weekdays like Sun, Mon, Tue, Wed, Thu, Fri and Sat.%bIt is used to abbreviate the names of the month like Jan, Feb, Mar, Apr, May, Jun, Jul, ... Read More

How can I use INTERVAL keyword with MySQL NOW() and CURDATE() functions?

Abhinanda Shri

Abhinanda Shri

Updated on 19-Jun-2020 13:46:05

1K+ Views

INTERVAL keyword with NOW() and CURDATE() MySQL functions can be used in similar fashion as it can be used with time, date or datetime units of a date value.ExampleUsing INTERVAL with MySQL NOW()mysql> Select NOW() + INTERVAL 2 day; +------------------------+ | NOW() + INTERVAL 2 day | +------------------------+ | 2017-10-30 ... Read More

Advertisements