Comparing row values in two different tables
Hello,
Does anyone know if it is possible to compare (and possibly highlight - which I know can be done) row values in two different tables?
I have a ZIP Code column in table A that I want to compare to a ZIP Code column in table B and highlight those ZIP Codes that are present in table B but not in table A etc. Is this possible?
Thanks,
Kenneth
To be able to apply conditional formatting, I must edit the formulas this way.
=IF(ISBLANK(B)," ",IF(ISERROR(VLOOKUP(B,Tableau 2 :: B,1,0))," ",VLOOKUP(B,Tableau 2 :: B,1,0)))
=IF(ISBLANK(B)," ",IF(ISERROR(VLOOKUP(B,Tableau 1 :: B,1,0))," ",VLOOKUP(B,Tableau 1 :: B,1,0)))
I replaces the four empty strings by strings containing one space character.
In the field supposed to contain the text which is not contained I just entered a single space character.
Yvan KOENIG (from FRANCE vendredi 12 septembre 2008 20:52:11)
Similar Messages
-
How to compare the contents of two different tables
hello. can somebody give me an idean on how to compare the contents of two different tables in mysql?
example, i have a table named Main List and a table named New List.
The contents of the New List should be compared to the contents of the
Main List, to check if they are equal. I don't have any idea how to manipulate
this data. Hoping for your help. Thanks.it is better to comapre it using java.. try get the resultset first and store that in collections then comapre the two collections
-
Comparing each value of two internal tables
HI everybody,
i have two internal tables itab1 and itab2 same structure
both r having four fields each and field with values
now i need to compare the two internal tables
and if every value of itab1 matches itab2
then i have to write one select quirie for the following given description
compare past and current shipping point
compare internal_table2 and internal_table3
if entry in internal_table2 and internal table3 match
variable_tknum = internal_table2-tknum
endif.
for each entry that matches:
select vlabdata into zi_vlabdata from vlbl where vbeln = variable_tknum and vlbl-vlabtyp = 'ZIBOOKNO'.
plz give me solution for this
thanks
hridhayanjili.sort : ITAB1 by f1,f2,f3,f4,
ITAB2 by f1,f2,f3,f4.
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY F1 = ITAB1-F1
F2 = ITAB1-F2
F3 = ITAB1-F3
F4 = ITAB1-F4 BINARY SEARCH.
IF SY-SUBRC = 0.
*--all the fields of ITAB1 and ITAB2 are matching .
*--write your logic here
ELSE.
*--ITAB1 and ITAB2 records are not matching.
ENDIF.
ENDLOOP.
Regards
Srikanth
Message was edited by: Srikanth Kidambi -
How to compare pixel values of two different grayscale images...
I have two different grayscale images both of much different sizes. One is 46x20 pixels and the other is 2592x1944 pixels. I'm having trouble finding a way to "scan" the smaller image through the larger one so that comparisons between the pixel values can be made. Basically I'm trying to see if anything matches the smaller image in the big image semi-closely. I can access the pixel values of each image but I can't figure out an algorithm to perform the scan. Any help at all would be very much appreciated! Thanks.
Hi
recipe:
1.
Find all the values for all the pixels in the small image. Some might be similar. Put all those values that are useful into a List called comparisonList.
2.
For each scanline in the large image
For each pixel in the scanline
is this pixel the same value as a pixel in the comparisonList?
if so do something
is the scanline finished?
if not next pixel
loop to next scanline
where scanline is a horizontal line in the big picture.
my 2c
hope helps -
How to create a dropdown list to list the values from two different tables?
Hi,
I have the following requirement:
1. I have to create a dropdown list to display all the values from the second column of a table.
2. Another dropdown list to display all the values from the second column of another table.
3. A text box should help me to add the selected values.
How to get this done in a PDF? Please help.
Regards,
LathaIs this a LC form? Because Acrobat forms have no concept of tables, just
individual fields... -
I have a mpp screen for a cd library management system (we are practicing on it).
We have a main screen where a user should enter the enteries and while clicking a add button it should be inserted in a table, Here the problem rises the table name are ztransaction and zstatus.The fields in mpp are cdid,customerid,transaction id,date of issue and duedate.Now after entering all the values on clicking add button it should be inserted to database table ztransaction and the field cdid alone should be inserted both in ztransaction and zstatus.
Thank youHi Raghuram R G,
Check for Primary key and foreign key in the Database table??? Because of this it was not inserting...check and confirm??
Regds,
Vijay SR -
Better approach for checking column values between two different rows
My requirement is to find best Approach to find difference between column values of two different rows.Below I've mentioned two different
approaches I'm thinking of,but I'd like to know is there any other better approach.
version details
SQL> SELECT *
2 FROM V$VERSION;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Solaris: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionTable creation script
CREATE TABLE R_DUMMY
(CA_ID VARCHAR2(16) NOT NULL ENABLE,
CA_VER_NUM NUMBER(4,2) NOT NULL ENABLE,
BRWR_SHORT_NAME VARCHAR2(25 CHAR),
sic_code number,
FAC_ID VARCHAR2(10) NOT NULL ENABLE
/ insert script
insert into r_dummy (CA_ID, CA_VER_NUM, BRWR_SHORT_NAME, sic_code, FAC_ID)
values ('CA2001/11/0002', 2.00, 'Nandu',1234, 'FA000008');
insert into r_dummy (CA_ID, CA_VER_NUM, BRWR_SHORT_NAME, sic_code, FAC_ID)
values ('CA2001/11/0002', 3.00, 'SHIJU',456, 'FA000008');Desired O/P :
ca_id fac_id column_name previous name after_modification
CA2001/11/0002 FA000008 BRWR_SHORT_NAME Nandu SHIJU
CA2001/11/0002 FA000008 sic_code 1234 456My approach
select ca_id,fac_id,column_name,
decode(column_name,'BRWR_SHORT_NAME',lg_brwr,lg_sic) previous_name ,
decode(column_name,'BRWR_SHORT_NAME',ld_brwr,ld_sic) after_modification
from
select
case
when ld_brwr != lg_brwr then
'BRWR_SHORT_NAME'
when ld_brwr != lg_brwr then
'sic_code'
end
) column_name,ca_id,fac_id,lg_brwr,ld_brwr,ld_sic,lg_sic
from (
select ca_id,fac_id,lag_brwr,ld_brwr,ld_sic,lag_sic
from
Select lead(brwr_short_name,1) over(partition by ca_id,fac_id) ld_brwr,
lag(brwr_short_name,1) over(partition by ca_id,fac_id) lg_brwr,
lead(sic_code,1) over(partition by ca_id,fac_id) ld_sic,
lag(sic_code,1) over(partition by ca_id,fac_id) lg_sic,
ca_id,fac_id
from r_dummy
where (ld_brwr != lg_brwr or ld_sic != lg_sic)
)2nd Approach :
=============
select ca_id,fac_id,column_name,
decode(column_name,'BRWR_SHORT_NAME',lg_brwr,lg_sic) previous_name ,
decode(column_name,'BRWR_SHORT_NAME',ld_brwr,ld_sic) after_modification
from
select
case
when ld_brwr != lg_brwr then
'BRWR_SHORT_NAME'
when ld_brwr != lg_brwr then
'sic_code'
end
) column_name,ca_id,fac_id,lg_brwr,ld_brwr,ld_sic,lg_sic
from (
select ca_id,fac_id,brwr_short_name,sic_code
from
Select ca_id,fac_id,brwr_short_name lg_brwr,sic_code lg_sic
from r_dummy
where ca_ver_num = '2.00'
)o,(
Select ca_id,fac_id,brwr_short_name ld_brwr,sic_code ld_sic
from r_dummy
where ca_ver_num = '3.00'
)n
where 0.ca_id = n.ca_id
and 0.fac_id = n.fac_id
and (ld_brwr != lg_brwr or ld_sic != lg_sic)
)Hi Experts,
I've provided sample data where I'm checking for just two columns viz brwr_short_name ,sic_code,but in real time
I've to check for 8 more columns so please suggest me with a better approach.
I appreciate your precious suggestions.Hi,
Thanks for posting the CREATE TABLE and INSERT statements; that really helps!
Here's one wa. Like your 2nd approach, this uses a self-join:
WITH got_r_num AS
SELECT ca_id
, ROW_NUMBER () OVER ( PARTITION BY ca_id
, fac_id
ORDER BY ca_ver_num
) AS r_num
, brwr_short_name
, TO_CHAR (sic_code) AS sic_code
, fac_id
-- , ... -- Other columns (using TO_CHAR if needed)
FROM r_dummy
, unpivoted_data AS
SELECT *
FROM got_r_num
UNPIVOT INCLUDE NULLS
( txt
FOR column_name IN ( brwr_short_name AS 'BRWR_SHORT_NAME'
, sic_code AS 'SIC_CODE'
-- , ... -- Other columns
SELECT p.ca_id
, p.fac_id
, p.column_name
, p.txt AS previous_name
, a.txt AS after_modification
FROM unpivoted_data p
JOIN unpivoted_data a ON p.ca_id = a.ca_id
AND p.fac_id = a.fac_id
AND p.column_name = a.column_name
AND p.r_num = a.r_num - 1
AND p.txt || 'X' != a.txt || 'X'
ORDER BY a.r_num
;To include other columns, add them in the 2 places where I put the comment "Other columns".
Ca_ver_num can have any values, not just 2.00 and 3.00.
This will show cases where a value in one of the columns changed to NULL, or where NULL changed to a value.
There ought to be a way to do this without a separate sub-query like got_r_num. According to the SQL Language manual, you can put expressions in the UPIVOT ... IN list, but when I tried
... UNPIVOT INCLUDE NULLS
( txt
FOR column_name IN ( brwr_short_name AS 'BRWR_SHORT_NAME'
, TO_CHAR (sic_code) AS 'SIC_CODE'
)I got the error "ORA_00917: missing comma" right after TO_CHAR. Perhaps someone else can show how to eliminate one of the sub-queries. -
Will a sequence return same value for two different sessions?
Is there a possibility that a sequence will return same value to two different sessions when it is referred exactly at the same instance of time?
@Justin... Thanks for your insight; indeed, we too feel this shouldn't ever happen and never heard of it either, but there it is. (No, we haven't logged a TAR yet -- whatever that is -- partly because it didn't occur to us and partly because we only recently came across the issue and sensibly want to do some testing before we cry foul.)
However, the code is pretty straight-forward, much like this (inside a FOR EACH ROW trigger body):
SELECT <seqname>.NEXTVAL INTO <keyvar> FROM DUAL;
INSERT INTO <tblname> (<keyfield>, <... some other fields>)
VALUES(<keyvar>, <... some other values> );
(where <tblname> is NOT the table on which the trigger is fired). This is the only place where the sequence is ever accessed. The sequence state is way below its limits (either MAXVALUE or <keyfield>/<keyvar> datatype size).
In this setup, end users sometimes got an out-of-the-blue SQL error to the effect that uniqueness constraint has been violated -- as I said, we used to have a unique index on <keyfield> -- which leads us to assume that the sequence generated a duplicate key (only way for the constraint to be violated, AFAIK). We released the constraint and indeed, using a simple SELECT <keyfield>, COUNT(*) FROM <tblname> GROUP BY <keyfield> HAVING COUNT(*)>1 got us some results.
Unfortunately, the <tblname> table gets regularly purged by a consumer process so it's hard to trace; now we created a logger trigger, on <tblname> this time, which tracks cases of duplicate <keyfield> inserts... We'll see how it goes.
@Laurent... winks at the CYCLE thing Our sequence is (needless to say) declared as NOCYCLE and the datatype is large enough to hold MAXVALUE. -
To find Common data in 2 columns in two different tables.
Hi,
Could someone help me out with a querry to find out common data from 2 columns in two different tables??
Thanks
Rajesh966915 wrote:
suppose i hav 2 tables
Table A
s.No name EID
1 aaa 123
2 bbb 234 ... etc..
and Table B
S.no salary eid location
1 mmm$ 123 india
2 ddd$ 556 Uk
3 fff$ 236 US
How do i select the common entry in both the tables??why do you post in forum for SQL & PL/SQL; yet never post anything in either language?
what do you mean by "common enrty"?
does every column value must match exactly across 2 rows in different table? -
Extracting unique records from two different tables record
Hello,
In the following code of two different tables www.testing.com exists in both tables. I want to compare two different columns of the two different tables to get unique records.
SQL> select unique(videoLinks) from saVideos where sa_id=21;
VIDEOLINKS
www.testing.com
SQL> ed
Wrote file afiedt.buf
1* select unique(picLinks) from saImages where sa_id=21
SQL> /
PICLINKS
test
test14
www.hello.com
www.testing.comThanks & best regardsUnfortunatly you didn't mention the expected output. I guess it would be the one line
"www.testing.com"
in that case simply join the two tables.
select *
from saVideos v
join saImages i on i.sa_id = v.sa_id and i.picLinks = v.videoLinks
where v.sa_id=21;If needed then you could change the select list to retrieve only distinct values.
select unique v.sa_id, v.videolinks
from saVideos v
join saImages i on i.sa_id = v.sa_id and i.picLinks = v.videoLinks
where v.sa_id=21;I usually avoid distinct/unique whereever possible. This requires the database to do a sort and makes the query slow.
Edited by: Sven W. on Feb 10, 2011 1:55 PM -
Selecting data from two different tables.
Do we need to use join two tables with primary/foreign key while trying to use select statement for getting data from those to table.? If no who can i go about do it.
872959 wrote:
If i am using From clause to get data from two different tables, is it necessary that both tables have column of identical data in them.In general, they ought to (or you need to join in a third table that tells you how to map rows from one table to rows of the other table).
It is not strictly necessary that there be any join condition between tables. If you don't provide a join condition, Oracle has to do a Cartesian product. That means that if there are n rows in one table and m rows in the other, the result set will have n * m rows. It is very rarely a good idea to write queries that do Cartesian products but it does occasionally happen.
Justin -
Insert same record on two different tables (no master detail)
Hi all,
I'd like to know how to insert 1 record into two different
tables.
the first table is corni_dati the second is cornidati_prev
anytime someone inserts a new record both tables should be
filled.
if ((isset($HTTP_POST_VARS["MM_insert"])) &&
($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO corni_dati (corni_id,
disciplina,
codice_modulo, insegnanti, classi, obiettivi, prerequisiti,
ud1, ud2,
ud3, ud4, ud5, ud6, metodologia, collegamenti, verifiche,
verifiche_note, durata, periodo_inizio, periodo_fine, note,
indirizzo,
modnum, modulo_titolo, `data`, compilato, descrizione) VALUES
(%s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s,
%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['corni_id'],
"int"),
GetSQLValueString($HTTP_POST_VARS['disciplina'],
"text"),
GetSQLValueString($HTTP_POST_VARS['codice_modulo'], "text"),
GetSQLValueString($HTTP_POST_VARS['insegnanti'],
"text"),
GetSQLValueString($HTTP_POST_VARS['classi'],
"text"),
GetSQLValueString($HTTP_POST_VARS['obiettivi'],
"text"),
GetSQLValueString($HTTP_POST_VARS['prerequisiti'], "text"),
GetSQLValueString($HTTP_POST_VARS['ud1'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud2'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud3'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud4'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud5'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud6'],
"text"),
GetSQLValueString($HTTP_POST_VARS['metodologia'], "text"),
GetSQLValueString($HTTP_POST_VARS['collegamenti'], "text"),
GetSQLValueString($HTTP_POST_VARS['verifiche'],
"text"),
GetSQLValueString($HTTP_POST_VARS['verifiche_note'], "text"),
GetSQLValueString($HTTP_POST_VARS['durata'],
"int"),
GetSQLValueString($HTTP_POST_VARS['periodo_inizio'], "text"),
GetSQLValueString($HTTP_POST_VARS['periodo_fine'], "text"),
GetSQLValueString($HTTP_POST_VARS['note'],
"text"),
GetSQLValueString($HTTP_POST_VARS['indirizzo'],
"text"),
GetSQLValueString($HTTP_POST_VARS['modnum'],
"text"),
GetSQLValueString($HTTP_POST_VARS['modulo_titolo'], "text"),
GetSQLValueString($HTTP_POST_VARS['data'],
"date"),
GetSQLValueString($HTTP_POST_VARS['compilato'],
"text"),
GetSQLValueString($HTTP_POST_VARS['descrizione'], "text"));
mysql_select_db($database_itiscorni, $itiscorni);
$Result1 = mysql_query($insertSQL, $itiscorni) or
die(mysql_error());
$insertGoTo = "creacodice_doc.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo));If you are doing this then you really should have a look at
your database
design. Read up on the first 3 normal forms.
Pat.
"darrel" <[email protected]> wrote in message
news:ee77jg$302$[email protected]..
>
>
> --
>> Hi all,
>> I'd like to know how to insert 1 record into two
different tables.
>
> In your SQL query, just use two inserts:
>
> INSERT into TABLE1...; INSERT into TABLE2...
>
> Darrel
> -
Query from two different tables
Hi All
I am having two different tables A and B. I want to select all rows containing the names like the rows in B.
I have tried the below and it does not work:
select * from A where name like (select '%'||name||'%' from B).
Can anyone help please.
Thanks
AmitHi Jeneesh
Thanks for the quick reply.
What i want is query to bring back all the name containing the string which is to be found in the table B.
Table A's content
Amit
Amita
Anjoo
Table B's Content
Ami
Query should return
Amit
Amita -
How to create a foreign key for the table from two different tables?
Hi All,
I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK tables. See the below code 2
code 1:
CREATE TABLE SAMPLE_CONS_CHECK
(NAME VARCHAR2(10),
SERIES VARCHAR2(5)
CREATE TABLE SAMPLE_CONS2_CHECK
(NAME VARCHAR2(5),
MODEL NUMBER
CREATE TABLE SAMPLE_CONS3_CHECK
(NAME VARCHAR2(5),
MODEL_NO NUMBER
)code 2
alter table SAMPLE_CONS_CHECK
add constraint SAMPLE_CONS_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS2_CHECK
add constraint SAMPLE_CONS2_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS3_CHECK
add constraint SAMPLE_CONS3_CHECK_pk primary key (NAME)
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK1 FOREIGN KEY
NAME
) REFERENCES SAMPLE_CONS_CHECK
NAME
) ON DELETE CASCADE;
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK2 FOREIGN KEY
NAME
) REFERENCES SAMPLE_CONS2_CHECK
NAME
) ON DELETE CASCADE;From the above schenario i am able to insert the data to SAMPLE_CONS3_CHECK table. But the parent data is already available in the parent table. The problem is here two different constarints from two different tables. While inserting, it is checking from both the tables whether the parent is exist or not.
How can i solve this problem? Can anyone halp me about this?
Thanks
Edited by: orasuriya on Aug 8, 2009 2:02 AMActually the design is completely incorrect.
What you say is
I have
'foo', 'foo series'
'foo','foo model'
'foo',666
By virtue of table3 referring to both table1 and table2.
This means you actually need to have 1 (one) table:
'foo','foo series','foo model', 666
And the 'problem' disappears.
Sybrand Bakker
Senior Oracle DBA -
How to load data from a flat file to two different tables at a time.
I am not aware of Sql Loader so Please any body suggest me that is there any way to load data from excel sheet to two different tables at a time its very urgent.
with regards,
Srinivas.RRead Utilities Guide from the Oracle Documentation Library. See
<br>
Oracle Database FAQs
</br>
Maybe you are looking for
-
PSE 10 won't open "CREATE" tab - stalls at "Initializing" (Mac OSX 10.6.8)
Hi everyone, I just purchased a copy of Photo Shop Elements & Premiere Elements 10 and can't get PSE to work properly. I can't use the "Create" tab - which is really annoying because it is the main reason I wanted PSE 10 for... So far I've tri
-
Command Line Parameters for Silent Install with Status for BI4.0 Products
For the XI3.1 product installations, which clearly leveraged MSIEXEC installation files, it was possible to use the /qb+ command line parameter to trigger a silent install which showed the progress of the installation with a final prompt to acknowled
-
From [http://www.delicious.com/askrefwt/Software__Linux?sort=alpha&order=asc http://www.delicious.com/askrefwt/Software__Linux?sort=alpha&order=asc] askrefwt's Software__Linux Bookmarks on Delicious I accessed [http://www.ubuntu.com/download/ubuntu/d
-
Having major OpenVPN difficulties [Self-solved]
EDIT: the problem was caused by this, in my /etc/openvpn/server.conf: log /var/log/openvpn/openvpn.log log-append /var/log/openvpn/openvpn.log ONLY ONE of those two lines is necessary; they are two different ways of logging to openvpn.log. Now that i
-
Call external function from SQL query
Hi, I am new to PL/SQL programming.I don't think this is possible but please let me know if there is a way to achieve this. I have a function written in VB.net and I would want to call from the query. create table temp as select id, callvbfunction(no