|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Using minus??
Hi..
I've got these 2 tables t1 |Emp_id|Name|Plant| |-A001-|ABCD|--A--| |-A002-|BCDE|--A--| |-A003-|CDEF|--A--| |-A004-|DEFG|--A--| |-A005-|EFGH|--A--| t2 |Emp_id|Name|Plant| |-B001-|ZYXW|--B--| |-B002-|YXWV|--B--| |-B003-|XWVU|--B--| |-B004-|ABCD|--B--| |-B005-|BCDE|--B--| I want to find the records in t1 that is not existing in t2 If i use MINUS; Code:
select * from t1 minus select * from t2 it will return back all records from t1, even the records that exists in t2 as i think only the Name column can be compare.Example: |Emp_id|Name|Plant| |-A001-|ABCD|--A--| |-A002-|BCDE|--A--| |-A003-|CDEF|--A--| |-A004-|DEFG|--A--| |-A005-|EFGH|--A--| When i try using; Code:
select name from t1 minus select name from t2 it return back the name in t1 that is not in t2..which is just a part of wat i want to do. Example: |Name| |CDEF| |DEFG| |EFGH| Is there a way to return all the columns in t1 and not only just the name? Example: |Emp_id|Name|Plant| |-A003-|CDEF|--A--| |-A004-|DEFG|--A--| |-A005-|EFGH|--A--| Should i be using MINUS or something else such as NOT EXISTS...but i do not really know how to do the NOT EXISTS thing. Can anyone help me figure out a way to do solve this?? Thanks YuLing Last edited by YuLing : April 23rd, 2004 at 03:58 AM. |
|
#2
|
|||
|
|||
|
Try that:
SELECT * from t1 WHERE name not in (SELECT name from t2) / |
|
#3
|
|||
|
|||
|
Thanks for ur help again
But why does the number of rows selected are different when i do this to double check... select name from t1 minus select name from t2; ------------------------------------- select name from t1 where name not in (select name from t2) The first query return more rows than the second one. ![]() |
|
#4
|
|||
|
|||
|
Your query is just fine, suppose to produce the same number of record(s).
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Using minus?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|