Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Searching 2 tables for Data where only one Table holds correct info


Message #1 by "Steve Redding" <steven.redding@u...> on Fri, 26 Jul 2002 12:53:12
The No. and type and sequence are not the same

the only guaranteed similarity is the agentID column

Any ideas?

Steven Redding
E-Commerce Web Development Team Leader
Zurich Insurance Company
www.eaglestar.co.uk
www.zurich.co.uk/personal
Tel. 01489 864804
Mob. 07764 282401


                                                                                                                    
                    Sanjeev                                                                                         
                    Gulati               To:     "sql language" <sql_language@p...>                         
                    <s.gulati@b...        cc:                                                                        
                    kport.nl>            Subject:     [sql_language] RE: Searching 2 tables for Data where only one 
                                         Tab le holds correct info                                                  
                    26/07/2002                                                                                      
                    14:41                                                                                           
                    Please                                                                                          
                    respond to                                                                                      
                    "sql                                                                                            
                    language"                                                                                       
                                                                                                                    
                                                                                                                    




Hi Steven,

then instead of doing a Querry like this u should place a UNION on the
tables
like

Select * from tblAgents a WHERE a.agentID='123'
UNION
Select * From tblStaff s s.agentID='123';


This query will work fine if the no and type and sequence of columns in
both
the tables is same. else u need to replace the * with the columns which are
common and in the sequence such as their data type is also same.

Regards
san

-Sanjeev Gulati
Quartz Consultant
TATA Consultancy Services
i-Broker Benelux PPM BV
DeBoelelaan 7 1083 HJ
Amsterdam, The Netherlands
Phone: +xxxx xxxxxxxxxx
       +0031 (20) 5400100 x205


-----Original Message-----
From: steven.redding@u... [mailto:steven.redding@u...]
Sent: Friday, July 26, 2002 1:58 PM
To: sql language
Cc: s.gulati@b...
Subject: [sql_language] RE: Searching 2 tables for Data where only one
Tab le holds correct info



Select *
From tblAgents a, tblStaff s
WHERE a.agentID='123' OR s.agentID='123'

Only one of the tables (tblAgents or tblStaff) will hold and agentID called
'123'

I need to get the rest of the data (e.g. name, address, postcode) that is
related to the record that has the agentID '123'

regards

Steve Redding
Steven Redding
E-Commerce Web Development Team Leader
Zurich Insurance Company
www.eaglestar.co.uk
www.zurich.co.uk/personal
Tel. 01489 864804
Mob. 07764 282401




                    Sanjeev

                    Gulati               To:     "sql language"
<sql_language@p...>
                    <s.gulati@b...        cc:

                    kport.nl>            Subject:     [sql_language] RE:
Searching 2 tables for Data where only one
                                         Tab     le holds correct info

                    26/07/2002

                    12:59

                    Please

                    respond to

                    "sql

                    language"









can u please write the querry so that we can look what are u trying to
fetch
and how?

Regards
-san

-----Original Message-----
From: Steve Redding [mailto:steven.redding@u...]
Sent: Friday, July 26, 2002 2:53 PM
To: sql language
Subject: [sql_language] Searching 2 tables for Data where only one Table
holds correct info


I need to search 2 tables (tblAgents, tblStaff) for records relating to a
UserID

Both Tables have a UserID field

A userID is unique and will ojnly appear in one of the tables..

When I run teh current Query I get the correct data returned but also data
from the other Table that is unrelated (i.e. the first record from the
other Table)

Anyone help?






___________________________________________________________________________

The information contained in this message is confidential and may be
legally privileged. If you are not the intended recipient, please do not
read, copy or otherwise use it and do not disclose it to anyone else.
Please notify the sender of the delivery error and then delete the
message from your system.

Any views or opinions expressed in this email are those of the author only.

Communications will be monitored regularly to improve our service and for
security and regulatory purposes.

Thank you for your assistance.

___________________________________________________________________________







  Return to Index