Join query

Results 1 to 2 of 2

Thread: Join query

  1. #1
    Join Date
    Dec 1969

    Default Join query

    Hello,<BR><BR>I have two SQL tables I_Master(I_ID,U_Name,U_City) and I_Users(I_ID,I_email,I_status). I_ID in I_Master table is the Primary key<BR>and identity.<BR><BR>There are lot of records in both the tables. for every I_ID in I_Master table there will be more than 1 records in I_Users table.<BR><BR>I am trying a query which will fetch records from these tables as mentioned below<BR><BR>select * from I_master IM,I_users IU where IM.I_ID=IU.I_ID and IM.U_Name=&#039;scott&#039; or IU.I_email=&#039;;<BR><BR>But its fetching duplicate records. I need to display records only whose IM.U_Name=&#039;scott&#039; or IU.I_email=&#039;;<BR><BR>Ple ase help<BR>

  2. #2
    Join Date
    Dec 1969

    Default Try this:

    [code language="T-SQL"]<BR>select *<BR>from I_master IM,<BR> I_users IU<BR>where IM.I_ID=IU.I_ID<BR> and (IM.U_Name=&#039;scott&#039; or IU.I_email=&#039;;)<BR>[/code]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts