Results 1 to 4 of 4

Thread: Join two tables using SQL query

  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Join two tables using SQL query

    SELECT * FROM HEADER_TABLE A, ITEM_TABLE B
    WHERE A.TRANSC_YEAR = B.TRANSC_YEAR
    AND A.INT_TRANSAC_KEY = B.INT_TRANSAC_KEY
    AND A.TRANSAC_INDICATOR = 'ISS'
    AND A.PROCESS_ID = 'P'
    AND B.TRANSAC_TYPE_CODE = 5.”

    my problem is that i only need a few fields from table HEADER_TABLE A and all fields from ITEM_TABLE B. but my table B contains around 60 fields.
    so i have to specify the name of each field instead of using * as both the tables have a few similar fields but with different values.

    Is dere any way other than specifying all the field names to fetch limited value from table A nd all the values from Item table B

  2. #2
    Join Date
    Nov 2008
    Posts
    1,022

    Re: Join two tables using SQL query

    So is it like you want to avoid those fields that are similar in each other? If it is the case then you can use WHERE clause in which you can use NOT EQUAL (<>) comparison to avoid those fields.

  3. #3
    Join Date
    Aug 2010
    Posts
    2

    Re: Join two tables using SQL query

    actually i need the fields from both the tables which could have same name but they can have different values. so i can't avoid those fields.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,022

    Re: Join two tables using SQL query

    Why don't you use subqueries in such case? First create a query where you check for validations in Table A. Include this query in subquery of another query where you make your validations for Table B. I hope I was clear in my point.

Similar Threads

  1. Cannot join big tables in Zynga Poker
    By rihit in forum Video Games
    Replies: 7
    Last Post: 23-11-2011, 08:05 AM
  2. Sql query with join
    By AZUL in forum Software Development
    Replies: 6
    Last Post: 07-11-2009, 12:00 AM
  3. SQL querry to join 2 tables from access dB
    By Aanand in forum Software Development
    Replies: 3
    Last Post: 09-05-2009, 05:15 PM
  4. SQL query between 2 tables linked by many to many relationship
    By Luis234 in forum Software Development
    Replies: 2
    Last Post: 09-05-2009, 02:17 PM
  5. SQL Query For Joining Three Tables
    By beelow in forum Software Development
    Replies: 4
    Last Post: 19-02-2009, 12:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,403,341.35569 seconds with 17 queries