- Trending Categories
- 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
110 Views
To find specific column names, use information_schema.columns Here, I am using Id in place of columnA and Name in place of columnB −mysql> select table_name as TableNameFromWebDatabase -> from information_schema.columns -> where column_name IN ('Id', 'Name') -> group by table_name -> having count(*) = 3;This will produce the following output. Following are the table with columns Id and Name −+--------------------------+ | TableNameFromWebDatabase | +--------------------------+ | student | | distinctdemo | | secondtable | | groupconcatenatedemo ... Read More
61 Views
You can avoid with the help of providing the value (NULL, 0, DEFAULT) with AUTO_INCREMENT. Let us first create a table −mysql> create table DemoTable1350 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1350 values(NULL, 'Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1350 values(0, 'Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1350 values(DEFAULT, 'Chris'); Query OK, 1 row affected (0.10 sec)Display all records ... Read More
255 Views
Let us first create a table −mysql> create table DemoTable1349 -> ( -> ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ProductPrice int -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1349(ProductPrice) values(7644); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable1349(ProductPrice) values(90843); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable1349(ProductPrice) values(9083); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1349(ProductPrice) values(10000); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement ... Read More
177 Views
Following is the syntax −select * from yourTableName order by yourColumnName=0, yourColumnName;Let us first create a table −mysql> create table DemoTable1348 -> ( -> Amount int -> ); Query OK, 0 rows affected (0.80 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1348 values(100); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1348 values(0); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1348 values(90); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1348 values(45); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1348 values(0); Query ... Read More
439 Views
For this, you can use the join concept. Let us first create a table −mysql> create table DemoTable1 -> ( -> Id int, -> Name varchar(10) -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(100, 'Bob'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select * from DemoTable1;This will produce the following output −+------+------+ | Id | Name | +------+------+ | 100 | Bob | +------+------+ 1 row in set (0.00 ... Read More
387 Views
Let us first create a table −mysql> create table DemoTable1345 -> ( -> UserEmailAddress text -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command. We have inserted email address here −mysql> insert into DemoTable1345 values('Carol123@gmail.com'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1345 values('987Sam@gmail.com'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1345 values('David_Miller@gmail.com'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1345 values('Bob@gmail.com'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select * ... Read More
235 Views
For this, use group by. Let us first create a table −mysql> create table DemoTable1344 -> ( -> `SequenceId` int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientId int, -> isMarried tinyint(1) -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1344(ClientId, isMarried) values(4567, 0); Query OK, 1 row affected (0.45 sec) mysql> insert into DemoTable1344(ClientId, isMarried) values(9876, 0); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1344(ClientId, isMarried) values(5432, 1); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1344(ClientId, isMarried) ... Read More
209 Views
Let us first create a table −mysql> create table if not exists DemoTable1343 -> ( -> `_ClientId` int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(40), -> ClientProjectDeadline date -> )ENGINE=MyISAM, AUTO_INCREMENT=1000; Query OK, 0 rows affected (0.21 sec)Insert some records in the table using insert command with a single query −mysql> insert into DemoTable1343(ClientName, ClientProjectDeadline) values('Chris', '2019-09-24'), ('Bob', '2015-12-09'), -> ('Mike', '2017-01-20'), ('Carol', '2018-03-31'); Query OK, 4 rows affected (0.10 sec) Records: 4 Duplicates: 0 Warnings: 0Display all records from the table using select statement −mysql> select * from DemoTable1343;This will produce the ... Read More
255 Views
For this, you can use MySQL row_number(). Let us first create a table −mysql> create table DemoTable1342 -> ( -> Score int -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1342 values(80); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1342 values(98); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1342 values(78); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1342 values(89); Query OK, 1 row affected (0.07 sec)Display all records from the table using select statement −mysql> select ... Read More
1K+ Views
To fetch the substring after last dot, use substring_index(). Let us first create a table −mysql> create table DemoTable1341 -> ( -> Value varchar(60) -> ); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1341 values('John.123.@gmail.com' ); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1341 values('Carol.Taylor.gmail') ; Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1341 values('C.MyFolder.Location') ; Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement −mysql> select * from DemoTable1341;This will produce the following ... Read More