How to use sub-query in mysql JOIN function ?

mysql-tutorials

How to use SUB QUERY in mySQL Join ?   In the below example, they having two tables one is SKU and another is ztmpBulkInsert. They are using ztmpBulkInsert table as sub query table and they are joining the table with master table column & secondary column example select s.skuCode, s.skuName, IFNULL(s.stock, 0) as POSStock, IFNULL(z1.stock, 0) PhysicalStock, ‘Stock Mismatch’ Remark from sku s left join ( select count(*) as stock, z.skuCode from ztmpBulkInsert z group by z.skuCode ) z1 on z1.skuCode = s.skuCode or z1.skuCode = s.skuCodePos where (IFNULL(s.stock,…

Read More

MySQL – Create temporary table

mysql-tutorials

How to create and drop Temporary table in MySQL  In MySQL, a temporary table is a special type of table that allows you to store a temporary result set. A temporary table is very handy when it is impossible or expensive to query data that requires a single SELECT statement with the JOIN clauses. In this case, you can use a temporary table to store the immediate result and use another query to process it. Create Temporary table SynTax CREATE TEMPORARY TABLE <<NEW TABLE>> SELECT * FROM EMPLOYEE Drop Temporary Table…

Read More

myTop – mySQL – Database – Performance Monitoring Tool

mysql-tutorials

myTop is one of free open source code to monitor mySQL Database in CUI mode. The terminal window show the statistics information about threads queries, uptime and more etc.., The tool helps to optimize and improve performance of mySQL to handle large request and response in the database server. How to install myTOP in Ubuntu ? sudo apt install mytop Configuring myTOP sudo nano /root/.mytop Copy and paste the default settings. host=localhost db=mysql delay=3 port=3306 socket= batchmode=0 color=1 idle=0 Connecting to myTOP :- sudo mytop -u <<USERNAME> –prompt Sample myTOP…

Read More

How to get last one hour data in MySQL ?

Last one Hour data in MySQL ? Example :- select o.code, o.customerId, c.name, c.email from `Order` o’; join Customer c on c.id = o.customerId ‘; where o.orderDate >= DATE_SUB(NOW(),INTERVAL <<SYNTAX>> HOUR) order by o.id limit 0, 2 Example :- select o.code, o.customerId, c.name, c.email from `Order` o’; join Customer c on c.id = o.customerId ‘; where o.orderDate >= DATE_SUB(NOW(),INTERVAL 1 HOUR) order by o.id limit 0, 2

Read More

How to import CSV file into Table in MySQL ?

Import CSV File into MySQL Table This below example shows you how to use the LOAD DATA INFILE statement to import CSV file into MySQL table. The LOAD DATA INFILE statement allows you to read data from a text file and import the file’s data into a database table very fast. Before importing the file, you need to complete the following steps : 1) Data Import table should be created 2) CSV Columns Should be match with the Database Table. 3) Access required to execute the query LOAD DATA INFILE…

Read More