472,119 Members | 953 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

need to combine these two queries

i have got two queries,
Expand|Select|Wrap|Line Numbers
  1. $sql1 = "select cust_id from customer where comp_name = '$compname'";
  2.  
  3.     $result = $DB->query($sql1);
  4.     $result->fetchInto($row);
  5.  
  6.     $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.
Jul 3 '08 #1
2 1550
r035198x
13,262 8TB
i have got two queries,
Expand|Select|Wrap|Line Numbers
  1. $sql1 = "select cust_id from customer where comp_name = '$compname'";
  2.  
  3.     $result = $DB->query($sql1);
  4.     $result->fetchInto($row);
  5.  
  6.     $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
Expand|Select|Wrap|Line Numbers
  1. "select expirydate from customer l,domain s
  2.  where l.cust_id = (select cust_id from customer where comp_name = '$compname') and s.domname =  '$domname'";
Jul 3 '08 #2
thanks that worked...
can we do the same thing using join
or was that one type of join
Jul 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Jamie Pittman via AccessMonster.com | last post: by
4 posts views Thread by Jason Gyetko | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.