- 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 4378 Articles for MySQL
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
571 Views
For this, use COLUMN_NAME and set LIKE with that specific column name. Let us find a specific column in an unknown table in a database −mysql> SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT -> FROM INFORMATION_SCHEMA.COLUMNS -> WHERE column_name LIKE '%StudentName%' -> AND table_schema = 'web';OutputThis will produce the following output −+-------------------+-------------+-----------+-------------+----------------+ | TABLE_NAME | COLUMN_NAME | DATA_TYPE | IS_NULLABLE |COLUMN_DEFAULT | +-------------------+-------------+-----------+-------------+----------------+ | demotable215 | StudentName | varchar | YES | NULL | | demotable221 | StudentName | varchar ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
146 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name text -> ); Query OK, 0 rows affected (1.31 sec)Insert some records in the table using insert command. Here, we have inserted a name with a specific word “name”, which we need to ignore −mysql> insert into DemoTable values('John 7'); Query OK, 1 row affected (0.65 sec) mysql> insert into DemoTable values('John 6'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable values('John 9'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable values('name John 3'); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
204 Views
Let us first create a table −mysql> create table DemoTable -> ( -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (1.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 'Smith'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 'Miller'); Query OK, 1 row affected (0.24 sec)Display all records from the table using ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
110 Views
Use the COLUMN_NAME to find which table in a database contains a specific column. Let us first create a table −mysql> create table DemoTable -> ( -> CustomerId int, -> CustomerName varchar(20), -> CustomerCountryName varchar(100) -> ); Query OK, 0 rows affected (1.05 sec)Following is the query to find in which tables a specific column “'CustomerCountryName'” is present −mysql> select *from information_schema.columns WHERE COLUMN_NAME = 'CustomerCountryName';OutputThis will produce the following output −+---------------+--------------+--------------+---------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+--------------+------------+-------+---------------------------------+----------------+-----------------------+-------+ | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME |ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE |CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH |NUMERIC_PRECISION ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
323 Views
Use the LPAD() function to left pad values. Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (2.26 secInsert some records in the table using insert command −mysql> insert into DemoTable values(857786); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(89696); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(89049443); Query OK, 1 row affected (0.25 secDisplay all records from the table using select statement −mysql> select *from DemoTable;OutputThis will produce the following output −+----------+ | ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
1K+ Views
Use equal to operator for an exact match −select *from yourTableName where yourColumnName=yourValue;Let us first create a table −mysql> create table DemoTable -> ( -> FirstName varchar(100), -> LastName varchar(100) -> ); Query OK, 0 rows affected (0.70 secInsert some records in the table using insert command −mysql> insert into DemoTable values('John', 'Smith'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('John', 'Doe'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
588 Views
Yes, we can combine IN and LIKE operators in MySQL using LIKE and OR operator. Let us first create a table −mysql> create table DemoTable -> ( -> SubjectTitle text -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Introduction To MySQL'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Java in Depth'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Coding with Python'); Query OK, 1 row affected (0.54 sec) mysql> insert into DemoTable values('C++ in Depth'); Query ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
194 Views
Use the MONTH() method in MySQL to select date based on month. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(10), -> UserPostMessageDate datetime, -> UserLikes int -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(UserName, UserPostMessageDate, UserLikes) values('John', '2019-01-31', 4560); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(UserName, UserPostMessageDate, UserLikes) values('Sam', '2019-06-28', 790); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable(UserName, UserPostMessageDate, UserLikes) values('Carol', '2019-05-01', ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
325 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ShippingDate datetime -> ); Query OK, 0 rows affected (1.16 sec)Insert some records in the table using insert command. Consider current date “2019-06-28” −mysql> insert into DemoTable(ShippingDate) values('2019-01-31'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(ShippingDate) values('2019-06-06'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(ShippingDate) values('2019-06-28'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(ShippingDate) values('2019-07-01'); Query OK, 1 row affected (0.16 sec)Display all records from the table ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
82 Views
You can use LIKE operator to conduct a basic search for last name. Let us first create a table: −mysql> create table DemoTable -> ( -> CustomerName varchar(100), -> CustomerAge int -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John Doe', 34); Query OK, 1 row affected (1.32 sec) mysql> insert into DemoTable values('David Miller', 24); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Bob Doe', 27); Query OK, 1 row affected (0.18 sec) mysql> insert into ... Read More