Loading Data Into A Table: Joining Tables
Loading Data Into A Table: Joining Tables
=================================================================
INDEX (FK_species),
==================================================================
====================================
Joining tables
Types of Join
SELF JOIN
SELECT a.label, b.label from menu a, menu b where a.id=b.parent;
(id, label, parent); 3 fields....
=====================================================================
====================
Views in Mysql
create view myview1 as select rollno "Rollno" ,name "Name" from stud_details;
delete
update
insert (null) .....
=====================================================================
=====================
Integrity Constraints
Foreign Key Constraint defined with on delete cascade
==================================================++++++++++++
+=============================
GROUP BY Clause
==================================================================
============================
DELIMITER $$
---------------------------------------------------------------------------------------------------------------------
---------------
DELIMITER ;
...............................................................................................................................
DELIMITER $$
DROP PROCEDURE IF EXISTS `inventory`.`myproc` $$
CREATE PROCEDURE `inventory`.`myproc` ()
BEGIN
declare c int;
set c= myfun();
select c;
END $$
DELIMITER ;
DELIMITER $$
DELIMITER ;
................................................................................................................
DELIMITER $$
DELIMITER ;
............................................................................................................................................
................................
DELIMITER $$
if mod(i,2)<>0 then
insert into new2 values(i);
end if;
set i=i+1;
end while loop1;
select * from new2;
END $$
DELIMITER ;
==================================================================
===========================
Triggers
delimiter %%
create trigger mytrig before insert on sails for each row
begin
declare id1 int;
declare qnty1 int;
set id1 = new.id;
set qnty1 = new.qnty;
update stock set qnty=qnty-qnty1 where id=id1;
end %%
delimiter;
==================================================================
==============================
CURSORS
DELIMITER $$
eloop:loop
fetch ORDERS_CURSOR into v_order_no;
select sum(qnty_ordered*prize) from orderdetails where order_no=v_order_no into
total;
if done=1 then
leave eloop;
end if;
CLOSE ORDERS_CURSOR;
select * from ORDERS_RESULTS;
END $$
DELIMITER;
==================================================================
==================