- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4219 Articles for MySQLi
303 Views
You can achieve this with the help of INSERT INTO SELECT statement. The syntax is as follows −INSERT INTO yourDatabaseName.yourTableName(SELECT *FROM yourDatabaseName.yourTableName);To understand the above syntax, let us create a table in a database and second table in another databaseThe database name is “bothinnodbandmyisam”. Let us create a table in the same database. The query is as follows −mysql> create table Student_Information -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(10), -> Age int -> ); Query OK, 0 rows affected (0.67 sec)Now you can insert some records in the ... Read More
830 Views
You can use a dynamic query for this. First set the variable name for username and variable name for a password. The syntax is as follows −SET @anyVariableName=’yourUserName’; SET @anyVariableName1=’yourpassword’;Now you can use the CONCAT() function from MySQL. The syntax is as follows −SET @yourQueryName = CONCAT (' CREATE USER "', @anyVariableName, '"@"localhost" IDENTIFIED BY "', @anyVariableName1, '" ' );Let us use the prepared statement PREPARE. The syntax is as follows −PREPARE yourStatementVariableName FROM @yourQueryName;Now you can execute the statement. The syntax is as follows −EXECUTE yourStatementVariableName;Deallocate the above using the DEALLOCATE PREPARE. The syntax is as follows −DEALLOCATE ... Read More
4K+ Views
You need to use ADD KEY to make a column with Key=MUL. The syntax is as follows −ALTER TABLE yourTableName MODIFY COLUMN yourColumnName data type, ADD KEY(yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table Instructor -> ( -> Instructor_Id int, -> Instructor_Name varchar(30), -> Instructor_CourseName varchar(100) -> ); Query OK, 0 rows affected (0.63 sec)Now you can look the table description of the table, the column KEY does not have any MUL key. The query is as follows to check the ... Read More
1K+ Views
To get rid of this error message, let us see a sample example. But before that let us go through the concept to fix it.Use variable to get the value from stored procedure. The variable will prefix with @ symbol. The syntax is as follows −CALL yourStoredProcedureName(yourParameter1, yourParameter2, ..........N, @yourVariableName);To see the value of variable you need to use select statement. The syntax is as follows −SELECT @yourVariableName;To understand the above syntax, let us create a table and insert some records in the table.The query to create a table is as follows −mysql> create table StoredProcedureDemo -> ( ... Read More
124 Views
You don’t need to use two where clauses. Use two conditions using the LIKE operator and AND operator.To understand how to use LIKE for this, let us create a table. The query to create a table is as follows −mysql> create table WhereDemo -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.56 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into WhereDemo values(101, 'Maxwell'); Query OK, 1 row affected (0.14 sec) mysql> insert into WhereDemo values(110, 'David'); Query ... Read More
10K+ Views
In MySQL, you can use two different types of quotation marks which is backtick and another is single quotes or double quotes. In this case, maybe you are using single quotes to the column name that’s why you are getting error. You need to use the backtick symbol (` `) instead of single quotes. Backtick can be used with column names while single quotes can be used for strings.To understand the above error, let us create a table. The query to create a table is as follows −mysql> create table Backtick_SymbolDemo -> ( -> Id int NOT NULL ... Read More
641 Views
You do not need to store a field PRICE as an int or as float in the database. For this, you can set the DECIMAL()..Most of the time integers can be used to represent the float point numbers and these integers are internally cast into DECIMAL() data type. Therefore, if you have field PRICE then always use DECIMAL() data type. The syntax is as follows −DECIMAL(M, D);Here, M represents the ‘TotalNumberOfDigit’ and D represents the ‘Number OfDigitAfterDecimalPoint’.To understand the above concept, let us create a table with field PRICE as DECIMAL data type. The query is as follows −mysql> create ... Read More
2K+ Views
To declare a datetime variable, you need to use a user-defined variable using the SET command. The syntax is as follows −SET @anyVariableName=’yourdatetimeValue’;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table datetimeVariables -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(10), -> ArrivalDatetime datetime, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. The query to ... Read More
245 Views
To return order of MySQL SHOW COLUMNS, you need to use ORDER BY clause. The syntax is as follows −SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ‘yourTableName’ AND column_name LIKE 'yourStartColumnName%' ORDER BY column_name DESC;Let us create a table in database TEST. The query to create a table is as follows −mysql> create table OrderByColumnName -> ( -> StudentId int, -> StudentFirstName varchar(10), -> StudentLastName varchar(10), -> StudentAddress varchar(20), -> StudentAge int, -> StudentMarks int ... Read More
186 Views
You will get an error whenever you return multiple rows in the benchmark. Return a scalar value or single row instead of multiple rows. The syntax is as follows −SELECT yourColumnName FROM yourTableName WHERE yourCondition.To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table UserDemo -> ( -> UserId int, -> UserName varchar(20), -> RegisteredCourse varchar(10) -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into UserDemo values(1, ... Read More