need to combine these two queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bips2005
    New Member
    • Jul 2008
    • 19

    need to combine these two queries

    i have got two queries,
    Code:
    $sql1 = "select cust_id from customer where comp_name = '$compname'";
    	
    	$result = $DB->query($sql1);
    	$result->fetchInto($row);
    	
    	$sql = "select expirydate from customer l,domain s where l.cust_id = '$row[0]' and s.domname =  '$domname'";
    the first query retrieves cust_id from the table customer and i use it in the second query to obtain expirydate.

    the problem here is that i need to combine these two queries into a single query to obtain the expiry date.
    i am fairly new to this.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by bips2005
    i have got two queries,
    Code:
    $sql1 = "select cust_id from customer where comp_name = '$compname'";
    	
    	$result = $DB->query($sql1);
    	$result->fetchInto($row);
    	
    	$sql = "select expirydate from customer l,domain s where l.cust_id = '$row[0]' and s.domname =  '$domname'";
    the first query retrieves cust_id from the table customer and i use it in the second query to obtain expirydate.

    the problem here is that i need to combine these two queries into a single query to obtain the expiry date.
    i am fairly new to this.
    Something like
    [CODE=php]
    "select expirydate from customer l,domain s
    where l.cust_id = (select cust_id from customer where comp_name = '$compname') and s.domname = '$domname'";[/CODE]

    Comment

    • bips2005
      New Member
      • Jul 2008
      • 19

      #3
      thanks that worked...
      can we do the same thing using join
      or was that one type of join

      Comment

      Working...