473,511 Members | 16,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need to combine these two queries

19 New Member
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 1594
r035198x
13,262 MVP
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
bips2005
19 New Member
thanks that worked...
can we do the same thing using join
or was that one type of join
Jul 3 '08 #3

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

Similar topics

3
2032
by: Alicia | last post by:
Hi, I am trying to match two queries and make it into one query. I have only been about to group similar attributes but nothing that looks like the FinalQuery below. If anyone knows of a query...
5
1909
by: Alicia | last post by:
Hello everyone based on the data, I created a union query which produces this. SELECT ,,, 0 As ClosedCount FROM UNION SELECT ,, 0 AS OpenedCount, FROM ORDER BY , ;
5
12973
by: Jamie Pittman via AccessMonster.com | last post by:
I have two tables with 5000 entries on them. One is based for regular time with several variables example (employee name, date,time in and out, code, customer, building) I have another table that...
4
5734
by: Jason Gyetko | last post by:
Is there any way to combine these two queries into one? I have tables Item_Master & Kit_Master which are the source tables. Query 2 is using both Item_Master (table) & qryKit1 (query) &...
3
1780
by: ConfusedMay | last post by:
Hi, I need to create a graph report that showed total hours and unattended hours based on certain months and operation code that user input into the form. I have two queries: one to calculate...
4
4206
by: PlayHard | last post by:
I want my output in two columns like this: C_INCIDENT_TYPE \ TOTAL COUNT How do I combine my two queries to get result. First Query SELECT C_INCIDENT_TYPE, COUNT (*)
4
2066
by: | last post by:
I have query1 where I set a date range. Query2 is a crosstab query and is based on query1. I don't want the queries to be saved in the mdb but I do want them to be run in VBA using a querystring. If...
1
3151
by: csolomon | last post by:
Hello: I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them...
13
3231
by: MNNovice | last post by:
I have three tables, tblAP, tblPayroll and tblAllocation. Each records three separate expenses. All three are related by FK ECHOID, each has common fields such as AccountNo, FundNo, GrantNo,...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.