469,325 Members | 1,651 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

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 1470
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.