473,799 Members | 2,837 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to join 2 queries into 1

I would like to know how to join 2 queries so that the results of these
2 queries show up in the same query:

SELECT b.bios_serial_n umber FROM bios b:
SELECT s.system_name FROM system s;

Basically I want to create a report that includes both system name and
serial number. I'm new to this and none of the JOIn documentation was
clear to me.

thanks!
PS

Mar 10 '06 #1
7 4162
Shanimal wrote:
I would like to know how to join 2 queries so that the results of these
2 queries show up in the same query: SELECT b.bios_serial_n umber FROM bios b:
SELECT s.system_name FROM system s; Basically I want to create a report that includes both system name and
serial number. I'm new to this and none of the JOIn documentation was
clear to me. thanks!
PS

We would need to see what columns are in each table so that we can see the
relationship between the 2 tables.

Example:
bios
systemid bios_serial_num ber
123 abc123456
124 abd345678

System
systemid system_name
123 somesystemname
124 someothername

select s.system_name,b .bios_serial_nu mber from bios b, system s
where b.???? = s.????;

s.???? and b.???? should contain a the same information pertaining to
system - like a systemID in the above example

Mar 10 '06 #2
"Shanimal" <sh******@att.n et> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
Basically I want to create a report that includes both system name and
serial number. I'm new to this and none of the JOIn documentation was
clear to me.


It's a lot of work, and probably not the best use of your time or ours, to
cover the basics on a newsgroup, when so many other materials already exist
for this purpose.

Find another document or tutorial on joins. Keep reading until you
understand joins. Joins are a fundamental concept in SQL, as fundamental as
loops are in most other programming languages. You must understand joins,
or else you might as well be using a spreadsheet.

Try a Google search for "sql join tutorial" and read a few of the free
tutorials available. Or pick up an introductory book like "SQL for Dummies"
(I'm not trying to be condescending, it's really a good book).

Regards,
Bill K.
Mar 10 '06 #3
Bill Karwin wrote:
[snip] Or pick up an introductory book like "SQL for Dummies"
(I'm not trying to be condescending, it's really a good book).
I concur.
Regards,
Bill K.

Mar 10 '06 #4
noone-

Thanks for trying to help!

I don't think there is a relation between the two tables. The BIOS
table holds the following info (columns):

bios_id
bios_uuid
bios_descriptio n
bios_manufactur er
bios_serial_num ber
bios_sm_bios_ve rsion
bios_version
bios_asset_tag
bios_timestamp
bios_first_time stamp

The BIOS doesn't include the system name.

The system table holds the following information (columns):

system_num_proc essors
system_memory
system_build_nu mber
net_ip_address
system_uuid
net_domain
net_user_name
net_client_site _name
net_domain_cont roller_address
net_domain_cont roller_name
system_model
system_name
system_part_of_ domain
system_primary_ owner_name
system_system_t ype
system_id_numbe r
system_vendor
time_caption
time_daylight
system_boot_dev ice
system_os_type
system_os_name
system_country_ code
system_descript ion
system_organisa tion
system_language
system_register ed_user
system_serial_n umber
system_service_ pack
system_version
system_windows_ directory
audit_type
firewall_enable d_domain
firewall_disabl enotifications_ domain
firewall_donota llowexceptions_ domain
net_domain_role
firewall_enable d_standard
firewall_disabl enotifications_ standard
firewall_donota llowexceptions_ standard
virus_manufactu rer
virus_version
virus_name
virus_uptodate
date_virus_def date
date_system_ins tall
system_timestam p
system_first_ti mestamp

The system table doesn't include any bios serial number.

I want the query to return the system name and bios serial number. So
far I can get one of the other, but not both together. What good is
getting a list of serial numbers for computers when you don't have a
computername?

I've read a couple of tutorials, I've searched the My SQL website and
google, the answer isn't clear. This is why I'm posting here, it's a
legit request. I'm not going to sign up for a class on this when the
newsgroup is readily avaialable and there are people out there willing
to help (there are)!

Mar 10 '06 #5
"Shanimal" <sh******@att.n et> wrote in message
news:11******** *************@i 40g2000cwc.goog legroups.com...
I don't think there is a relation between the two tables.


You said you want both the system name and the bios serial number. Which
bios serial number goes with which system name?

This is the concept of a join: to express the criteria for matching rows of
one table to rows of another table. How they match up is the relationship
between the two tables.

It's possible that you do not have the right information in these two tables
to express the relationship. This would naturally make it hard to envision
the join criteria.

For instance, as in noone's example, it is typical that there is a column
that appears in both tables. Where you find identical values in that column
in both tables, that's the definition of rows that match. But you don't
seem to have that column in common between the two tables, so you may have
no expressable relationship given the current state of the data.

The other possibility is that you need a third table to express the
relationship. This is useful if one bios can match multiple systems, and
also one system can match multiple bios's. This is called a "many-to-many"
relationship. You'd need to join this third table to both the bios table
and the system table in one query, in order to match up all the entries.

Regards,
Bill K.
Mar 10 '06 #6

Bill Karwin wrote:
"Shanimal" <sh******@att.n et> wrote in message
news:11******** *************@i 40g2000cwc.goog legroups.com...
I don't think there is a relation between the two tables.


You said you want both the system name and the bios serial number. Which
bios serial number goes with which system name?

This is the concept of a join: to express the criteria for matching rows of
one table to rows of another table. How they match up is the relationship
between the two tables.

It's possible that you do not have the right information in these two tables
to express the relationship. This would naturally make it hard to envision
the join criteria.

For instance, as in noone's example, it is typical that there is a column
that appears in both tables. Where you find identical values in that column
in both tables, that's the definition of rows that match. But you don't
seem to have that column in common between the two tables, so you may have
no expressable relationship given the current state of the data.

The other possibility is that you need a third table to express the
relationship. This is useful if one bios can match multiple systems, and
also one system can match multiple bios's. This is called a "many-to-many"
relationship. You'd need to join this third table to both the bios table
and the system table in one query, in order to match up all the entries.

Regards,
Bill K.


Bill-

Thanks for taking the time to explain this to me. It totally makes
sense now, after reading just the first paragraph you posted. I was
missing the concept now I get it. As you mentioned, there has to be
some relationship connecting them. Within the system table I found that
system_id_numbe r is the same as the bios serial number so I can figure
out the join concept and get the info that I need.

thanks again!
PS

Mar 10 '06 #7
Shanimal wrote:
Bill Karwin wrote:
"Shanimal" <sh******@att.n et> wrote in message
news:11****** *************** @i40g2000cwc.go oglegroups.com. ..
I don't think there is a relation between the two tables.


You said you want both the system name and the bios serial number. Which
bios serial number goes with which system name?

This is the concept of a join: to express the criteria for matching rows of
one table to rows of another table. How they match up is the relationship
between the two tables.

It's possible that you do not have the right information in these two tables
to express the relationship. This would naturally make it hard to envision
the join criteria.

For instance, as in noone's example, it is typical that there is a column
that appears in both tables. Where you find identical values in that column
in both tables, that's the definition of rows that match. But you don't
seem to have that column in common between the two tables, so you may have
no expressable relationship given the current state of the data.

The other possibility is that you need a third table to express the
relationshi p. This is useful if one bios can match multiple systems, and
also one system can match multiple bios's. This is called a "many-to-many"
relationshi p. You'd need to join this third table to both the bios table
and the system table in one query, in order to match up all the entries.

Regards,
Bill K.

Bill-

Thanks for taking the time to explain this to me. It totally makes
sense now, after reading just the first paragraph you posted. I was
missing the concept now I get it. As you mentioned, there has to be
some relationship connecting them. Within the system table I found that
system_id_numbe r is the same as the bios serial number so I can figure
out the join concept and get the info that I need.

thanks again!
PS

Based on this statement:
"Within the system table I found that system_id_numbe r is the same as
the bios serial number so I can figure out the join concept and get the
info that I need."

now you can just

select syste_name,syst em_id_number as bois_serial_num ber from system;

This query "renames" the column name at select time to be whatever you
want it to be...

without having to do a join at all... the purpose of a join is retrieve
non-repeating data from the 2(or more) tables.
Mar 11 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3075
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me solve my problem. I'll turn to MySQL doc after getting through this pressing project. Thanks a lot Roger! Babale -----Urspr=FCngliche Nachricht-----
1
3457
by: Paul Bramscher | last post by:
Here's one for pathological SQL programmers. I've got a table of things called elements. They're components, sort of like amino acids, which come together to form complex web pages -- as nodes in trees which form parent-child relationships, sort of like newsgroups. For example, the parent_id field points to another element. Indent_level is there for denormalization purposes, to avoid costly recursive issues in querying. The...
1
2270
by: Beachvolleyballer | last post by:
hi there anyone had an idea to join following 2 queries to 1???? ----- QUERY 1 --------------------------------------------- SELECT TMS_CaseF_2.Name AS TCDomain_0, TMS_CaseF_3.Name AS TCDomain_1, TMS.CaseF.Name AS TCFolder_2, TMS_CaseF_1.Name AS TCFolder_3,
2
3679
by: Greg Stark | last post by:
I find I often want to be able to do joins against views where the view are aggregates on a column that has an index. Ie, something like SELECT a.*, v.n FROM a JOIN (select a_id,count(*) as n group by a_id) as v USING (a_id) where there's an index on b.a_id. assume there are other tables being joined so I can't just move the aggregate to the outermost layer.
3
23101
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but he doesn't know how to do that, or even if he can, and i don't have to time to learn DB2 from scratch right now. The following SQL Query is a trimmed sample of the full View (i.e. Logical) definition - and i would create it on an SQL based...
2
3359
by: HS Hartkamp | last post by:
Hi all, I have a table with analysis-results for various months. An item can -for a particular month- have the result 'list1', 'list2' or 'list3' depending on the result of the analysis. Next, I want to get an insight in how the various items change over time. For that, I compare the results of one month with the results of another month. The form in which I want this is a cross-tab-query with one month as a row-header and another...
9
3212
by: Alan Lane | last post by:
Hello world: Background: Yesterday, January 21, Doug Steele was kind enough to help me out on a Left Join problem. I was trying to return all stores and their Gross Adds for December, 2004 (even though some of them had no Gross Adds for that month). My query would only show the non-zero GA stores. Doug stated "It's because of the Where clause. The stores which don't have any records for the period in question are being eliminated...
3
1522
by: mariohiga | last post by:
Hello I've a really big doubt :) I've this two alternatives SELECT * FROM T1 a INNER JOIN T1 b ON a.F1 = b.F1 AND a.F2 = 1 SELECT *
14
2497
by: cjakeman | last post by:
Hi, Solved a little mystery yesterday when I built a form that combined 2 tables with a 1:M relationship and relational integrity. All the correct data was visible on the form but, if I tried to edit any of the fields, the PC bleeped. Seems it was due to the query the form was based on. Again, editing any of the fields of the query caused the PC to bleep.
2
2251
by: frederikengelen | last post by:
Hello all, We are seeing strange behaviour for queries on a table we need to convert data from. We try to find out whether table A(B_CONV_ID) contains data that does not exists in table B(CONV_ID). We expect that there is data missing in table B, thus finding a positive number of records. There are two tables, A and B.
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.