- 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
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
679 Views
You can search for a string within text column in MySQL with the help of LIKE clause. The syntax is as follows −select *from yourTableName where yourColumnName like '%anyStringValue%';To use the above syntax, let us first create a table −mysql> create table SearchTextDemo −> ( −> BookName TEXT −> ); Query OK, 0 rows affected (0.55 sec)Insert some strings in the table. The query is as follows −mysql> insert into SearchTextDemo values('Let us C'); Query OK, 1 row affected (0.28 sec) mysql> insert into SearchTextDemo values('C in Depth'); Query OK, 1 row affected (0.14 sec) ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
2K+ Views
To count how many rows have the same value using the function COUNT(*) and GROUP BY. The syntax is as follows −SELECT yourColumName1, count(*) as anyVariableName from yourTableName GROUP BY yourColumName1;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table RowWithSameValue −> ( −> StudentId int, −> StudentName varchar(100), −> StudentMarks int −> ); Query OK, 0 rows affected (0.55 sec)Insert some records with same value. Here, we have added same marks for more than one student for our example. The query ... Read More
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
3K+ Views
The equivalent of Java long in the context of MySQL variables is BigInt.In Java, the long datatype takes 8 bytes while BigInt also takes the same number of bytes.Demo of Java longHere is the demo of Java long −public class JavaLongDemo { public static void main(String[]args) { long kilometer = 9223372036854775807L; System.out.println("The largest positive value for long range:"+kilometer); } }The following is the output −Demo of BigIntLet us see an example of BigInt type in MySQL. The following is the query to ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
801 Views
For random numbers in a range, you need to use the RAND() method from MySQL. The syntax is as follows for update −UPDATE yourTableName set yourColumnName=value where yourColumnName2=(SELECT FLOOR(1+RAND()*3));In the above query, the statement FLOOR(1+RAND()*3) generates the number between 1-3 and update the column.To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table updateRowWith1To3 -> ( -> Id int, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
666 Views
No, you won’t get any issues with underscores in a MySQL table name. You will get the issues with a dash in a MySQL table name.Here is the demo that does not have any issue with underscore with table names −_StudentTrackerDemoLet us see the same while creating a table. The query to create a table is as follows −mysql> create table _StudentTrackerDemo -> ( -> StudentId int, -> StudentFirstName varchar(100) -> ); Query OK, 0 rows affected (0.75 sec)The underscore is valid for table names but dash is ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
You can create a table from view using create table select syntax. The syntax is as follows −CREATE TABLE yourTableName AS SELECT yourColumnName1, yourColumnName2, yourColumnName3, ........N from yourViewName;To run the above query, first you need to create a table and after that you need to create a view on that table. After that run the query.First, you need to create a table. The query to create a table is as follow −mysql> create table StuedntInformation -> ( -> Id int, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.54 sec)Above, we have created a ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
324 Views
You can achieve this with the help of INFORMATION_SCHEMA.TABLES. Use the date_sub() with interval. The syntax is as follows −SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE DATE_SUB(NOW(), INTERVAL -1HOUR) < ‘UPDATE_TIME’;Now you can check the above syntax. Here is the query to find the tables modified in the last hour −mysql> select table_name from `INFORMATION_SCHEMA`.`TABLES` -> WHERE -> DATE_SUB(NOW(), INTERVAL 1 HOUR) < `UPDATE_TIME`;Output+---------------------+ | TABLE_NAME | +---------------------+ | innodb_table_stats | | innodb_index_stats | | employeeinformation | +---------------------+ 3 rows in set (0.37 sec)The above query selects only table name. If you want information like table schema, table ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
834 Views
You can use SELECT IF statement with OR. To understand select with OR, let us create a table. The query to create a table is as follows −mysql> create table EmployeeInformation -> ( -> EmployeeId int, -> EmployeeName varchar(100), -> EmployeeStatus varchar(100) -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into EmployeeInformation values(1, 'Sam', 'FullTime'); Query OK, 1 row affected (0.23 sec) mysql> insert into EmployeeInformation values(2, 'Mike', 'PartTime'); Query OK, 1 row affected (0.14 sec) mysql> ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ Views
In MySQL, there is no way to truncate with condition. You cannot use truncate statement with where clause.If you want the condition, use delete command −DELETE FROM yourTableName WHERE youCondition;The above syntax is fine but if you want a faster solution, then DELETE is not good in comparison to Truncate. The advantage with truncate is that it does not write to the logs.Let us create a table. The query to create a table is as follows −mysql> create table DeleteDemo -> ( -> Id int, -> Name varchar(100) ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
Whenever you retrieve datetime from a table, the datetime gives ‘YYYY-MM-DD’ format. If you want to change the output, then you need to use in-built date_format() from MySQL.The syntax is as follows −SELECT DATE_FORMAT(yourDatetimeColumnName, yourFormat) as anyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table UserDateFormat -> ( -> ProductId int, -> ProductDeliverDate datetime -> ); Query OK, 0 rows affected (0.93 sec)Insert some records in the table using insert command. The ... Read More