How to join 2 tables?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Exequiel
    Contributor
    • Jul 2012
    • 288

    How to join 2 tables?

    I have this code in codeIgniter, the data doesn't output with that code, how can I output the data using join in code Igniter?
    Code:
    $userId=$this->session->userdata('uid');
    		$utype= $this->session->userdata('utype');
    		
    		if($utype == 5){
    			
    			
    			$checkUser = "SELECT across_client_admin.clientId, accross_client.clientName, accross_client.clientAddress,accross_client.clientContactNumber,accross_client.clientEmailAddress
    								FROM across_client_admin
    								INNER JOIN accross_client
    								ON across_client_admin.clientId=clientId.clientId
    								WHERE across_client_admin.clientCompanyUserAccountId=$userId";
    								
    		$DB = $this->load->database('default', TRUE);
    		$QueryNow = $DB->query($checkUser);
    		$count=0;
    		foreach($QueryNow ->result() as $vals):
    			
    			$sd = $vals->clientName;
    			
    		endforeach;
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    I would add some 'log_message('le vel', 'message')' to your code.

    The results of your query can be checked real quick by adding
    a line after line14 to check the if any records are returned at all
    Code:
    log_message('level', 'Number of records found:'.$query->num_rows() );

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Code:
      FROM across_client_admin
      INNER JOIN accross_client
      ON across_client_admin.clientId=clientId.clientId
      Your join is wrong. You have no table named clientId. I'm surprised it didn't error on you.

      Comment

      Working...