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

MySQL – Change Column type to DATETIME with TimeStamp

mysql-tutorials

How to change existing database table column to AUTO DATE TIME field & Value. Simple command to change the existing column to AUTO TIME STAMP Syntax :- ALTER TABLE `<TABLE NAME>` CHANGE COLUMN `<COLUMN NAME>` `<COLUMN NAME` TIMESTAMP NOT NULL DEFAULT ‘0000-00-00 00:00:00’ Example ALTER TABLE `stockTr` CHANGE COLUMN `createdDate` `createdDate` TIMESTAMP NOT NULL DEFAULT ‘0000-00-00 00:00:00’

Read More

Disable copy paste in HTML without Javascript

html5 sample code

There are simple function available in HTML 5 itself to avoid drag & drop in the textbox or text area and disable paste in the textbox or text area. HTML Tag onDrop to use to stop drag any items into the textbox / textarea HTML Tag onPaste to use to stop paste values into the textbox / textarea. Sample :- <input type=”textare” ondrop=”return false;” onpaste=”return false;”> <textarea rows=”4″ cols=”50″ ondrop=”return false;” onpaste=”return false;”> CheckedResponsive.com Site </textarea>

Read More

How to create user to taking backup only in mySQL ? MySQL

mysql-tutorials

Is there simple command available to give limited access the user to take backup the database in mySQL WorkBench with limited access. Step : 1 CREATE USER ‘username’@’%’ IDENTIFIED BY ‘pa$$w0rd’; Step : 2 GRANT SELECT, SHOW VIEW, LOCK TABLES, RELOAD, REPLICATION CLIENT ON *.* TO ‘userName’@’%’; Step: 3 FLUSH PRIVILEGES; The users not required INSERT or ALTER TABLE privileges to take backup te database. The above set of privileges enough to take the backup from the mysqldump programs. And it will be sufficient to backup database also.  

Read More