Found 4381 Articles for MySQL

MySQL Error ERROR 1099 (HY000): Table was locked with a READ lock and can't be updated

AmitDiwan
Updated on 19-Nov-2020 10:54:59

711 Views

To get rid of LOCK TABLES query, you need to use UNLOCK TABLES.Let us create a table −mysql> create table demo6 −> ( −> country_name varchar(100 −> ) −> ); Query OK, 0 rows affected (1.51 sec)Insert some records into the table with the help of insert command −mysql> insert into demo6 values('US'); Query OK, 1 row affected (0.11 sec) mysql> insert into demo6 values('UK'); Query OK, 1 row affected (0.08 sec) mysql> insert into demo6 values('AUS'); Query OK, 1 row affected (0.11 sec)Display records from the table using select statement −mysql> select *from demo6;This will produce the ... Read More

Limit total number of results across tables in MySQL?

AmitDiwan
Updated on 19-Nov-2020 10:48:20

188 Views

For this, you can use UNION ALL along with LIMIT concept. For our example, we will create three tables.Let us create the first table −mysql> create table demo3 −> ( −> value int −> ); Query OK, 0 rows affected (1.39 sec)Insert some records into the table with the help of insert command −mysql> insert into demo3 values(10); Query OK, 1 row affected (0.13 sec) mysql> insert into demo3 values(20); Query OK, 1 row affected (0.08 sec) mysql> insert into demo3 values(30); Query OK, 1 row affected (0.08 sec)Display records from the table using select statement −mysql> select ... Read More

Multiple LIKE Operators with ORDER BY in MySQL?

AmitDiwan
Updated on 19-Nov-2020 10:40:51

240 Views

Following is the syntax implementing multiple LIKE operators with ORDER BY −select *from yourTableName order by (    yourColumnName like '%yourValue1%' ) + (    yourColumnName like '%yourValue2%' ) + . . N desc;Let us create a table −mysql> create table demo2 −> ( −> id int not null auto_increment, −> name varchar(100), −> primary key(id) −> ); Query OK, 0 rows affected (1.53 sec)Insert some records into the table with the help of insert command −mysql> insert into demo2(name) values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert into demo2(name) values('David'); Query OK, 1 row affected (0.09 ... Read More

How to get number located at 2 places before decimal point MySQL?

AmitDiwan
Updated on 19-Nov-2020 10:37:16

200 Views

In order to get number located at 2 places before decimal point, you can use the concept of div.Let us create a table −mysql> create table demo1 −> ( −> value float −> ); Query OK, 0 rows affected (2.20 sec)Insert some records into the table with the help of insert command −mysql> insert into demo1 values(456.54); Query OK, 1 row affected (0.16 sec) mysql> insert into demo1 values(50.64); Query OK, 1 row affected (0.17 sec) mysql> insert into demo1 values(1000.78); Query OK, 1 row affected (0.13 sec)Display records from the table using select statement −mysql> select *from demo1;This will ... Read More

How to select subsets of data In SQL Query Style in Pandas?

Kiran P
Updated on 10-Nov-2020 06:52:12

354 Views

IntroductionIn this post, I will show you how to perform Data Analysis with SQL style filtering with Pandas. Most of the corporate company’s data are stored in databases that require SQL to retrieve and manipulate it. For instance, there are companies like Oracle, IBM, Microsoft having their own databases with their own SQL implementations.Data scientists have to deal with SQL at some stage of their career as the data is not always stored in CSV files. I personally prefer to use Oracle, as the majority of my company’s data is stored in Oracle.Scenario – 1 Suppose we are given a ... Read More

Creating a MySQL Docker Container

Raunak Jain
Updated on 27-Oct-2020 08:07:38

513 Views

One of the most important features of Docker Containerization is that it creates a bounded environment for running the Application with all the necessary dependencies and packages installed. Most applications require a backend database to store data points. Oracle provides Docker Images for running MySQL inside Containers and thus it becomes an excellent choice for testing your database applications. It provides lightweight MySQL Image instances with cleanup features once your testing is completed.Docker allows you to download the Image containing the MySQL binaries and dependencies and creates a virtual filesystem. Note that if you start a Docker Container with the ... Read More

Convert timestamp coming from SQL database to String PHP?

AmitDiwan
Updated on 12-Oct-2020 13:26:15

467 Views

To convert timestamp to string, use setTimestamp(). Let’s say the following is our input i.e. timestamp −$SQLTimestamp = 1600320600000;We want the following output i.e. Date string −2020-09-17 05:30:00At first, get seconds from Timestamp −$seconds = round($SQLTimestamp/1000, 0);Example Live Demo Output2020-09-17 05:30:00

Sum of the first and last digit of a number in PL/SQL

sudhir sharma
Updated on 06-Aug-2020 08:15:02

1K+ Views

In this problem, we are given a number n. Our task is to create a program to find the sum of the first and last digit of a number in PL/SQL.First, let’s brush-up about PL/SQL, PL/SQL is a combination of SQL along with the procedural features of programming languages.Let’s take an example to understand the problem, Input − n = 31415Output − 8Explanation − first digit = 3 , last digit = 5. Sum = 8To, solve this problem, we will extract the first and last digit to number n. And the print their sum.The first and last digits are ... Read More

Difference between Simple and Complex View in SQL

Nitin Sharma
Updated on 09-Jun-2020 09:02:15

3K+ Views

Before discussing on Simple and complex, first we should know what is View. A View is the logical virtual table created from one or more tables which can be primarily used to fetch the columns from one or more different tables at a time. On the basis of tables involved in the view we can distinguish between Simple and Complex View in SQL.Following are the important differences between Simple and Complex View.Sr. No.KeySimple ViewComplex View1DefinitionSimple View in SQL is the view created by involving only single table. In other words we can say that there is only one base table ... Read More

Difference between Views and Materialized Views in SQL

Kiran Kumar Panigrahi
Updated on 23-Dec-2024 19:33:23

60K+ Views

The main constituent of any database is its tables, in order to make data accessibility custom there is concept of Views in other words we can say that with the help of Views of a table we can restrict any user to access only that data which is supposed to be accessed by him. Now on the basis of characteristic and features of the views we can distinguish between Views and Materialized Views. In this article, we will discuss the important differences between Views and Materialized Views in SQL. But before, let’s have look into the basics of views and ... Read More

Advertisements