Sql query with join

Posted on 2011-10-05
Last Modified: 2012-08-13
Need to create a query with following selection criteria
1.Select * from tableA,tableB where tableA.refno = tableB.refno and  tableB.Cu_track_lg_datadate is null
2.Also include members who do not have tableB

Question by:RIAS
    LVL 22

    Accepted Solution


    Seams like you need a left join, try

    select * from tableA
    left join tableB on tableA.refno = tableB.refno
    where tableB.Cu_track_lg_datadate is null or tableB.refno is null



    Author Closing Comment

    Cheers mate!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now