2 Replies Latest reply on Jun 6, 2014 4:45 PM by Frank Kulash

    Sql statement with join and where condition




      I am new the world of SQL and have basic understanding of writing simple queries.  I am tring to join data from several tables and have been sucessful at doing so, however for one table I need to apply a Where condition so only particular data is joined.  Question is how can I incorporate a Where column = 12 in a statement that has multiple joins.



        • 1. Re: Sql statement with join and where condition


          welcome to community.

          You have a select with join clauses, right ? Or do you join manually in a where clause ?

          Simply add your condition in the where clause. The table from which you column comes has an alias i think, so just do

               where <alias or table_name>.column = 12


          That's all.

          Or post your complete query then we see how to help you.



          btw please choose a more readable name for your avatar. Thanks

          • 2. Re: Sql statement with join and where condition
            Frank Kulash



            Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.

            Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.

            Simplify the problem as much as possible.  If you need to join several tables, but the part you don't know how to do can be shown using only 2 tables, then post a problem using only those 2 tables.

            Always say which version of Oracle you're using (for example,

            See the forum FAQ: https://forums.oracle.com/message/9362002#9362002


            If all the joins are inner joins, then you can just put that condition in the WHERE clause.  (Add a WHERE clause immediately after the FROM clause if there isn't already a WHERE clause.)

            If some of the joins are outer joins, you might need to put that condition in the join conditions.  It depends on your data and your requirements.