$objConn = setDbConn();
  	
  	$strSQL  = "CALL mp_proc_getHomePageProjNews('Chennai')";  	
  	
	 if($objConn->multi_query($strSQL)) 
	 {
		do 
		{		
	  		$l = 0;
				/* store first result set */
				if ($result = $objConn->use_result()) 
				{
	
					while($row = $result->fetch_row()) 
					{
					  $arrTempResult[] = $row;
					}
	
					$arrResult[] = $arrTempResult;						
					unset($arrTempResult);
													
					$result->close();
				}
			
				if($objConn->more_results()) 
				{
				}			 
		 } while ($objConn->next_result());
	 } 
create table fruits(fruit_id int, fruit_name VARCHAR(255));  
create table type(fruit_id int, status VARCHAR(255));

INSERT INTO fruits(fruit_id, fruit_name) 
            values(101, 'Apple'),
                  (102, 'Mango'),
                  (103, 'Lemon'),
                  (104, 'Grape'),
                  (105, 'Orange');

INSERT INTO type(fruit_id, status) 
          values(101, 'Edible'),
                (101, 'Sweet'),
                (102, 'Edible'),
                (103, 'Edible'),
                (103, 'Salty'),
                (103, 'Sour'),
                (104, 'Sour');

When i Use Inner Join as Below the Output would be

To prevent the repetition of fruit name the queries are as follows

SELECT f.fruit_id, f.fruit_name
  FROM fruits f
 WHERE f.fruit_id in(SELECT DISTINCT fruit_id
                       FROM type);

SELECT DISTINCT t.Fruit_id, fruit_name
  FROM fruits f RIGHT OUTER JOIN
       type t ON F.Fruit_id = t.Fruit_id;

SELECT fruits.*
  FROM fruits inner join
       type on type.fruit_id = fruits.fruit_id
  GROUP BY type.fruit_id;
Posted in SQL.

After installing apache in CentOS it would go to Apache 2 Test Page.

To locate this directory you need to go to /var/www/
In this directory you can create your file which you needs to run.

To set up Virtual Host navigate to /etc/httpd/conf/httpd.conf file

Open the file in gedit or editor of your preference.

Add the lines below

<VirtualHost *:80>
   DocumentRoot /var/www/sample/
   ServerName virtualhost1
</VirtualHost>

The document root points out to sample older in www directory

The server name is virtual host name you type in URL

You should also add the code in /etc/hosts file

127.0.0.1    virtualhost1

 

Once this is done dont forget to restart apache server in terminal by typing service httpd.restart

Now you are ready to go now.Open the browser and type http://virtualhost1/

Cheers!!!

Table Creation Script

CREATE TABLE Customers(Row_Id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
                       Cust_Name VARCHAR(255),
                       Created_Date DATE,
		       Cust_Status TINYINT)

The Rows in the table are as Below

INSERT INTO Customers(Cust_Name, Created_Date, Cust_Status)
               VALUES('Customer A', '20120516', 0),
                     ('Customer B', '20120516', 0),
                     ('Customer C', '20120516', 0),       
                     ('Customer A', '20120517', 1),
                     ('Customer B', '20120517', 0),
  		     ('Customer C', '20120517', 0),
		     ('Customer A', '20120520', 1),
		     ('Customer B', '20120520', 0),
	             ('Customer C', '20120520', 1),
		     ('Customer A', '20120521', 0),
                     ('Customer B', '20120521', 0),
		     ('Customer C', '20120521', 1),                                                               
                     ('Customer A', '20120526', 1),
		     ('Customer B', '20120526', 1),				 	
                     ('Customer C', '20120526', 0),				 	
                     ('Customer A', '20120530', 1),
		     ('Customer B', '20120530', 1),				 		
                     ('Customer C', '20120530', 0);

I want to take the rows which changes their Cust_Status from 0 to 1 only for first time.
When I run the script by giving 20120517 as parameter to where clause it should return Customer A.
When I run the script by giving 20120520 as parameter to where clause it should return Customer C.
When I run the script by giving 20120526 as parameter to where clause it should return Customer B.

SELECT  C.Cust_Name
  FROM  Customers C
 WHERE  C.Created_Date = '20120526' AND
        C.Cust_Status  = 1          AND
        NOT EXISTS (SELECT c2.Cust_Name
  	              FROM Customers c2
      		     WHERE c2.Cust_Name   = C.Cust_Name AND
	                   c2.Cust_Status = 1 AND
	                   c2.Created_Date &lt; C.Created_Date)
Posted in SQL.

How to call Static Method in Another Package
Sample4.java

package com.scjp.test;

public class Sample4 
{
  public static void CallMe()
  {
   System.out.println("I am Static in Another Package");	
  }

  public static void main(String[] args) 
  {	
  }
}

Sample6.java

import com.scjp.test.*;

public class Sample6 
{
  public static void main(String[] args) 
  {
    Sample4.CallMe();
  }
}