Karthikeya Boyini has Published 1698 Articles

Insertion in a MySQL table with only a single column set as auto_increment?

karthikeya Boyini

karthikeya Boyini

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

192 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId int NOT NULL AUTO_INCREMENT,    -> PRIMARY KEY(StudentId)    -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command. Here, we have inserted a value, but since ... Read More

Set Bounds for JProgressBar in Java Swing

karthikeya Boyini

karthikeya Boyini

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

416 Views

Use the setBounds() method to set Bounds for JProgressBar in Java Swing −JProgressBar progressBar; progressBar.setBounds(70, 50, 120, 30);The following is an example to set bounds for JProgressBar −Examplepackage my; import javax.swing.*; public class SwingDemo extends JFrame {    JProgressBar progressBar;    int i = 0;    SwingDemo() {     ... Read More

How will implement Your Own sizeof in C

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

To use the sizeof(), we can take the value using a variable x, using &x, it will print the address of it. Now if we increase the value of &x then it may increase in different way. If only one byte is increased, that means it is character, if the ... Read More

How can we set Mnemonic Key Radio Button in Java?

karthikeya Boyini

karthikeya Boyini

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

535 Views

Mnemonic key is set so that a user can use Keyboard keys to select a Radio Button. For example, a key can be set with ALT −radio2.setMnemonic(KeyEvent.VK_R);Above, we have set key ALT+R for radio2.The following is an example to set Mnemonic key radio button −package my; import java.awt.FlowLayout; import java.awt.event.KeyEvent; ... Read More

Can we skip a column name while inserting values in MySQL?

karthikeya Boyini

karthikeya Boyini

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

840 Views

Yes, we can do that. Let us first create a table −mysql> create table DemoTable    -> (    -> StudentName varchar(100),    -> StudentAge int    -> ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentAge) values(23); Query ... Read More

How to correctly use INSERT INTO … SELECT in MySQL to avoid Error 1064?

karthikeya Boyini

karthikeya Boyini

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

717 Views

Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> FirstName varchar(100)    -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(FirstName) values('John'); Query ... Read More

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

272 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

225 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

Advertisements