try this .. Its not tested bcoz i dont have sql in my machine..
This code will not work as there are null values in the column of join..However it may work for this particular problem as it is having only one Null value.But in case there are multiple null values in the table,This query will fail
I want to perform join on these 2 tables.
...
The output should be like this:
...
Your data looks like this:
You want to fetch records from both tables that have:
(1) NULL values for both map_code and data_code columns, or
(2) Non-NULL and identical values for map_code and data_code columns respectively.
In a join condition, Oracle takes care of case no. (2) already. So for case no. (1), you could use the NVL function and set the column value to something that both sides agree upon mutually.
Here's an example:
Of course, you'd want to ensure that the "mutually agreed upon" value is something that *NEITHER* of the two columns could assume.
(To understand why, imagine the output of Query 1 if table1.map_code is null and table2.map_code is "~").
A way out is to use a non-printable character, like so -
Otherwise, if you are a truly paranoid programmer, then you probably won't rely on default values; you would be as explicit as you could be -
tyler_durden
Last edited by durden_tyler; 08-24-2011 at 10:26 PM..
Hi,
Please let me know if you have any thoughts on how to read a table that has all the oracle sql files or shell scripts at the job and step level to identify all the tables that does merge, update, delete, insert, create, truncate, alter table (ALTER TABLE XYZ RENAME TO ABC) and call them out... (1 Reply)
Hello,
This post is already here but want to do this with another way
Merge multiples files with multiples duplicates keys by filling "NULL" the void columns for anothers joinning files
file1.csv:
1|abc
1|def
2|ghi
2|jkl
3|mno
3|pqr
file2.csv:
1|123|jojo
1|NULL|bibi... (2 Replies)
What I have:
I have a input.sh (script which basically connect to mysql-db and query's multiple tables to write back the output to output1.out file in a directory)
note: I need to pass an integer (unique_id = anything b/w 1- 1000) next to the script everytime I run the script which generates... (3 Replies)
Hi..
We have a table DB_QUERIES, in which sql queries are stored.
SQL> desc DB_QUERIES
Name Null? Type
----------------------------------------- -------- ----------------------------
QUERY_ID NOT NULL NUMBER(10)
... (2 Replies)
I want to check for rows in a table where all values (except the key) is empty. I am using MySQL 5.5.
I plan to do this mechanically, so the approach should work for any table in my database schema.
Suppose for illustration purposes I start with the following table:
CREATE TABLE `sources` (
... (4 Replies)
Hello;
I want merge four MySQL tables to get the intersection that have a common field for all of them. Join two tables is fine to me, but my this case is different from common situations and there are not very many discussions about it. Can anybody give me some idea? Thanks a lot!
Here is part... (8 Replies)
Hi,
I have a requirement as below which needs to be done viz UNIX shell script
(1) I have to connect to an Oracle database
(2) Exexute "SELECT field_status from table 1" query on one of the tables.
(3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
example sql:
select a.a1,b.b1,c.c1,d.d1,e.e1
from a
left outer join b on a.x=b.x
left outer join c on b.y=c.y
left outer join d on d.z=a.z
inner join a.t=e.t
I know how single outer or inner join works in sql.
But I don't really understand when there are multiple of them.
can... (0 Replies)
I'm pretty new to the database world and I've run into a mental block of sorts. I've been unable to find the answer anywhere. Here's my problem: I have several tables and everything is as normalized as possible (as I've been lead to understand normalization.) Normalization has lead to some... (1 Reply)
I am coding shell script.
I need to connect to different databases like DB2, Oracle and Sybase.
I would then need to query tables where it has all the groups, users for that database.
I would also need who has what kind of permissions.
EG: I know for DB2 some TABAUTH table needs to be... (0 Replies)