Karthikeya Boyini has Published 2192 Articles

How can we grant a user to access all stored procedures in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

1K+ Views

Let us first display all users and host from the table MySQL.user −mysql> select user, host from Mysql.user;This will produce the following output −+------------------+-----------+ | user             | host      | +------------------+-----------+ | Bob              | %   ... Read More

Print a long int in C using putchar() only

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

2K+ Views

Here we will see how to print long int value using the putchar() function in C. We can easily print the value of some variables using printf() in C, but here the restriction is, we cannot use any other function except putchar().As we know that the putchar() is used to ... Read More

Can we return query results in same order as the values in MySQL `IN(…)` statement?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

246 Views

Yes, you can achieve this with ORDER BY FIELD() from MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using ... Read More

How to display grant defined for a MySQL user?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

209 Views

Use SHOW GRANTS for this. Following is the syntax −SHOW GRANTS FOR 'yourUserName'@'yourHostName';Let us display the user name and host name from MySQL.user table.mysql> select user, host from MySQL.user;This will produce the following output −+------------------+-----------+ | user | ... Read More

Split a column after hyphen in MySQL and display the remaining value?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

713 Views

To split a column after hyphen, use the SUBSTRING_INDEX() method −select substring_index(yourColumnName, '-', -1) AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> StreetName text -> ); Query OK, 0 rows affected (0.60 sec)Insert ... Read More

How to cut part of a string with a MySQL query?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

388 Views

For this, use substring_index() function from MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> StudentId varchar(100) -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert ... Read More

Write your own memcpy() in C

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

3K+ Views

Here we will see how to implement memcpy() function in C. The memcpy() function is used to copy a block of data from one location to another. The syntax of the memcpy() is like below −void * memcpy(void * dest, const void * srd, size_t num);To make our own memcpy, ... Read More

How to extract the area codes from a phone number with MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

1K+ Views

Let’s say we have a list of phone numbers and from that we want to get the area codes. These area codes are for example, the first 3 digits of the phone number. Use LEFT() function from MySQL for this.Let us first create a table −mysql> create table DemoTable -> ... Read More

Best data type for storing large strings in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

921 Views

You can use text data type to store large strings. Following is the syntax −CREATE TABLE yourTableName (    yourColumnName text,    .    .    N );Let us first create a table −mysql> create table DemoTable -> ( -> MyStringValue text ... Read More

Average of first n even natural numbers?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:26

1K+ Views

Average or mean of n even natural number is the sum of numbers divided by the numbers.You can calculate this by two methods &minusFind the sum of n even natural numbers and divide it by number, Using loop.Find the sum of n even natural numbers and divide it by number, ... Read More

Advertisements