String comparison between columns in different tables
Hi allI have two tables. Table A and table B with Column3 column Column1 respectively I would search for lines in the Table B Column3 containing strings that exist in table Column1 has.
For example,.
Table A table B
< here >
Column1 Column3
< here >
Vol01/net/ddrr-pp01-ts001/flight/vol03
vol02 \\ddrr-xx01-ts001\yy123-ds02
vol03/net/ddrr-zz01-ts001/flight/vol01/4555/xxx
XXX01 \\ddrr-pp01-ps001\vol01\yyyy\
xx0333/net/ddrr-pp01-ds001/flight/vol01/xxx/77777
/ net/ddrr-pp00-ts001/flight/vol02 yy123-ds02
I tried to play with substr but have not found it is repeating until I wanted to do... with something like this
Select a.column1, b.column3 from tableA, tableB b where a.column1 = substr (b.column3, 5, max (length (a.column1)))
Any help to guide me in the right direction will be greatly appreciated.
Thank you.
Or we can use the combination of SUBSTR and INSTR REGEXP_LIKE:
with a as (
select 'vol01' column1 from dual union all
select 'vol02' from dual union all
select 'vol03' from dual union all
select 'xxx01' from dual union all
select 'xx0333' from dual union all
select 'yy123[ds02' from dual
),
b as (
select '/net/ddrr-pp01-ts001/vol/vol03' column3 from dual union all
select '/net/ddrr-pp01-ts001/vol032/123' from dual union all
select '\\ddrr-xx01-ts001\yy123[ds02' from dual union all
select '/net/ddrr-zz01-ts001/vol/vol01/4555/xxx' from dual union all
select '\\ddrr-pp01-ps001\vol01\yyyy\' from dual union all
select '/net/ddrr-pp01-ds001/vol/vol01/xxx/77777' from dual union all
select '/net/ddrr-pp00-ts001/vol/vol02' from dual
),
-- end of on-the-fly data sample
c as (
select column1,
column3,
instr(column3,column1) position
from a,
b
where instr(column3,column1) > 0
)
select column1,
column3
from c
where regexp_like(substr('!' || column3,position),'\W')
and regexp_like(substr(column3 || '!',position + length(column1)),'\W')
/
COLUMN1 COLUMN3
---------- ----------------------------------------
vol01 /net/ddrr-zz01-ts001/vol/vol01/4555/xxx
vol01 \\ddrr-pp01-ps001\vol01\yyyy\
vol01 /net/ddrr-pp01-ds001/vol/vol01/xxx/77777
vol02 /net/ddrr-pp00-ts001/vol/vol02
vol03 /net/ddrr-pp01-ts001/vol/vol03
vol03 /net/ddrr-pp01-ts001/vol032/123
yy123[ds02 \\ddrr-xx01-ts001\yy123[ds02
7 rows selected.
SQL>
SY.
Tags: Database
Similar Questions
-
Oracle how to multiply two columns of different tables and results
Oracle how to multiply two columns of different tables and get the result in the third column?
I want to multiply all the lines of the quantinty column in the table of quantity with the relevant lines of the table of prices price column and get the result of multiplying in the third column. What should I use procedure trigerr? OR IS IT POSSIBLE HOW TO DO IT PLEASE HELP :D
Edited by: 994229 2013-03-15 12:44/* Formatted on 3/15/2013 3:51:08 PM (QP5 v5.185.11230.41888) */ CREATE TABLE mytable1 AS (SELECT 1 id, 5 VALUE FROM DUAL UNION ALL SELECT 2, 7 FROM DUAL UNION ALL SELECT 3, 8 FROM DUAL); CREATE TABLE mytable2 AS (SELECT 1 id, 4 VALUE FROM DUAL UNION ALL SELECT 2, 12 FROM DUAL UNION ALL SELECT 10, 12 FROM DUAL); SELECT id, mytable1.VALUE, mytable2.VALUE, mytable1.VALUE * mytable2.VALUE product FROM mytable1 FULL OUTER JOIN mytable2 USING (id) ORDER BY id;
ID VALUE VALUE_1 PRODUCT 1 5 4 20 2 7 12 84 3 8 10 12
-
Select cursor for update: multiple columns of different tables
Hello
I have two tables test1 and test2. I want to udpate the column (DEPT_DSCR) from the TEST1 and TEST2 using select for update and current tables of the... with the cursor.
I have a code drafted as follows:
DECLARE
v_mydept1 TEST1. TYPE % DEPT_CD;
v_mydept2 TEST2. TYPE % DEPT_CD;
CURSOR C1 IS SELECT TEST1. DEPT_CD, TEST2. DEPT_CD OF TEST1, TEST2 WHERE TEST1. DEPT_CD = TEST2. DEPT_CD AND TEST1. DEPT_CD IS 'AA' FOR THE UPDATE OF TEST1. DEPT_DSCR, TEST2. DEPT_DSCR;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO v_mydept1, v_mydept2;
WHEN EXIT C1% NOTFOUND;
UPDATE TEST1 SET DEPT_DSCR IS "PLSQL1" WHERE CURRENT OF C1;.
SETTING A DAY TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1.
END LOOP;
COMMIT;
END;
The code above when it is run, declares that it runs successfully. But it does not update the columns you want [DEPT_DSCR].
It works only when we want to update one or more columns of the same table... i. e by providing these columns after ' to UPDATE THE.
I don't know what exactly is the problem when you want to update several columns of different tables.
Can someone help me on this?user12944938 wrote:
But it's more the notion of compensation and understanding.See the link below:
http://download.Oracle.com/docs/CD/B10501_01/AppDev.920/a97269/pc_06sql.htmSee the section RESTRICTION in the link above.
Twinkle
-
Hello
I have two tables USERS and LISTS:
And I want that there is a comparison between these two tables executed when user table USERS connect to the application.
They must compare the columns between the SEXES and AGE and if some users have the same attributes in its ranks as in a line in the table LISTS (here is unique each line) so that the user gets in his line in the column 'LIST_ID' the ID of the line with which attributes between GENDER and AGE.
Example:
USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. -------
LISTS OF TABLE: 28 | examplelist | Male | 18
Once the Login of the user Boby gets in its ranks the ID = 28 because the SEX and AGE corresponds to the row of table LIST:
Result:
USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. 28
CREATE TABLE "USERS" ( "USERNAME" VARCHAR2(15) NOT NULL ENABLE, "FORRNAME" VARCHAR2(15) NOT NULL ENABLE, "SURNAME" VARCHAR2(15) NOT NULL ENABLE, "GENDER" VARCHAR2(10) NOT NULL ENABLE, "AGE" NUMBER, "LIST_ID" NUMBER, CONSTRAINT " USERS_PK" PRIMARY KEY ("USERNAME") USING INDEX ENABLE
CREATE TABLE "LISTS" ( " LIST_ID" NUMBER NOT NULL ENABLE, " LISTNAME" VARCHAR2(50) NOT NULL ENABLE, "GENDER" VARCHAR2(10) NOT NULL ENABLE, "AGE" VARCHAR2(3) NOT NULL ENABLE, CONSTRAINT " LISTS_PK" PRIMARY KEY ("LIST_ID") USING INDEX ENABLE
I need help for coding this, if someone be so good.
This is my essay:
DECLARE v_listid varchar2(100); BEGIN SELECT LIST_ID into v_listgid FROM LISTS WHERE GENDER = (SELECT GENDER FROM USERS WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER))) AND AGE = (SELECT AGE FROM USERS WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER))); UPDATE USERS SET LIST_ID = v_listid WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER)); END;
I'd like to REALLY shy away using the USER name as the primary key, because the fact that users can create duplicate user names... YOU should NEVER base a PK on the entry of user, the better to let the database create and maintain this element of date...
FIX:
UPDATE to users U
SET List_Id = (SELECT List_Id OF lists L WHERE L.Gender = U.Gender and L.SOMENUMBER = U.SOMENUMBER) AND
Upper (U.UserName) = UPPER(:APP_USER);
Don't really want to cut the strings, Oracle which will do since they are of type varchar2 columns...
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILL -
Comparison between a static value type String and a type perhaps unrelated number
Well I have another question of my book of text... so far I typed in exactly how they ask me to and even followed some screenshots of examples of theres. All me looks good, but of course, I'm the only one with an untrained eye.
When I run this film I get a compiler error of: 1176 20 comparison between a static value type String and a type perhaps unrelated to line number
Here is my code
import flash.events.MouseEvent;
Stop();
var numberOfCookies:Number = 0;
startBtn.addEventListener (MouseEvent.CLICK, getCookies);
function getCookies(event:MouseEvent)
{
numberOfCookies = (Math.floor (Math.random () * (10)) + 1);
var n: Number = 0;
While (n < numberOfCookies)
{
var cookieInstance:cookieMC = new cookieMC;
addChild (cookieInstance) .x = (Math.random () * 200) + 20, (cookieInstance) there (Math.random () * 150) = + 220;
n ++ ;
}
}
goBtn.addEventListener (MouseEvent.CLICK, checkNumberTyped);
function checkNumberTyped(event:MouseEvent)
{
If (checkBox.text == numberOfCookies) //this is the line 20
{
gotoAndPlay (2);
}
on the other
{
gotoAndPlay (3);
}
}The error indicates well enough the problem... the compiler doesn't like to compare different types of things. In your case, a type is a string, and the other type is a number. If you need to force one of them to become another type, and you can go either way...
If (checkBox.text is String (numberOfCookies))
OR
If ((checkBox.text) Number is numberOfCookies)
-
How to get into two different tables in two columns of a listbox of multi column
Hi all
I have two different tables of the values assume that table 1A (1,2,3,4,5) and another table B (3,4,5,6,7). I want to write these tables in a multicolumn listbox such as 1st column would be A array and 2nd column table B.
Thnx in advance
Saki,
I hope this helps to further
-
To find common data in 2 columns from two different tables.
Hello
Could someone help me with a querry to discover common data of 2 columns from two different tables?
Thank you
RajeshTry as below.
select col1 ,col2 from tab1 intersect select col1 ,col2 from tab2;
-
How to find the same column name in different tables in the same schema
Hello
I find the 'ename' column name in different tables in the same schema.
Thank you
NrHello
Try this query
Select column_name, table_name from user_tab_columns where column_name = 'ENAME ';
Award points and end the debate, if your question is answered or mark if she was...
Kind regards
Lacouture.
-
Single column supporting different FK of various tables [Design issue]
What would be a good design for a table with a column that can be worth a few different tables FK.
The Fk constraint doesn't have to be applied.
My thought is to simply make an int with another column in the table that defines the origin of the value.
Is there a better way to do it?
Thank youIf the FK column in this table must exist in the table of a parent or another? Hmmm. As FK relationships must be able to be provided by the database to be useful, maybe...
Create two columns, one for the FK to one parent and one for the FK to parent b. You can then declare the FK relationship in the database so that it can enforce and make profit in the optimization of queries. Then add a check constraint to the table to assert that none of the columns is null, and only one of then has a value (while the other is null). Outer join to both tables parent with a DECODING on the query returns the appropriate parent (research) value of the result set.
SELECT c.col_a,
DECODE( p1.col_b, NULL, p2.col_c, p1.col_b )
FROM child c,
parent_a p1,
parent_b p2
WHERE c.id = p1.c_id (+)
AND c.id = p2.cid (+); -
Hello
Oracle version: Oracle Database 11 g Release 11.1.0.7.0 - 64 bit Production
The version of SQL Developer: 4.0.2.15 - 15.21 build
I have a question about drawing diagram, entity-relationship with SQL Developer & I would be grateful if you could kindly give me a helping hand.
I would like to draw an entity-relationship diagram in order to better visualize the relationship between multiple tables. After a google search, I found the following interesting article indicating the procedure to be followed:
http://www.Oracle.com/technetwork/issue-archive/2014/14-may/o34sqldev-2193423.html
(What I need and I'm trying to produce is Figure 4 in the article above)
I made exactly as stated in the article & apparently everything has worked well enough, in other words, I had several UML as rectangles showing columns of tables, their data types, primary and
foreign key and the arrows indicating the link between each parent/child table.Later, I tried to do the same thing on a different oracle instance and a different database by using the same procedure. Yet, something strange happened this time. Developer SQL printed on-screen tables, once again,.
inside the rectangles with types, keys,... but, there was no arrow showing the link between the tables, I just saw on the grid the selected tables but without any association/relationship shown (as a symbol of an arrow)
between them.I repeated the procedure on another instance of development, with a few test tables that I created with primary and foreign keys just to make sure I had followed the procedure correctly. Once again
the test was successful, but when I repeated the test on another instance, the same problem persisted, in other words, no arrow (relationship) between tables.
Any idea?
This could be due to a lack of privilege on the instance? If Yes, what should be granted in what about roles?
Thanks in advance
I think that what you see is that not all databases have foreign keys - applications hard-coding relationships vs let the database to handle this.
Connect to this instance different oracle and browse the tables affected - have FK constraints defined on them?
-
Mapping of columns with different data type of sql teradata source target
Hello
I get a problem after upgrading our version of the Golden Gate to Version 11.2.1.0.13 17435036.
Source DB: Sql Server
Target the DB: Teradata
We have generated the definition file and put it in the target server.
The table structure for one of the target server table differs from the source server. Average datatype of some columns in a table is different than it is in the source.
During replication, it throws an error that incompatibility of data type.
Is there a keyword in Oracle Golden Gate, that we can use in parameter files to eliminate this error where Golden Gate will automatically match the columns.
Before this upgrade version of Golden Gate in the source and target, everything worked well.
Any help in this direction will be really appreciated.
Bipul Singh
Hi, ok, I knew this could be the case, but wanted to check your DDL first, but a change in the way BIT data types are stored in the path took place between versions 11.1 and 11.2. The ILO data are coming in the target as 0x00 and 0x01, which SQL Server manages without conversion, but other targets will have to use the @NUMBIN function in your COLMAP clause to convert the BIT smallint. And I don't actually know that the SMALLINT will map correctly, but I believe that is should.
Here is an example:
card dbo.XXX, target "SCHEMA". "" XXX_T0 ", colmap (usedefaults Roving_Bit=@NUMBIN (Roving_Bit)...
You will have to do for all types of data BIT also.
-
How to set the value of a column in a table according to another column?
Hello world!
I use Apex 4.1.
My question is how can I set the value of a column in a table according to another column?
I have a table and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).
I tried to use javascript as
for the development of the column note to test if the value typed in the content of the column is not 1, but this code assigns the value to all the lines and I need to set only the specified line.$('input[name=f02]').live('change', function(){ if($(this).val()!='1'){ $('input[name=f03]').val("test")} });
Can someone give me a hint in any way to do this if possible?
Kind regards
drama9346You will need create a process on your page type PLSQL and develop this process "we demand" of the page. In this process, you can run the PLSQL you need. That is to say to retrieve the note value as described in your PC:
and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).
In this process, you must provide a return value of the call, and you can do this by using htp.p. Example:
DECLARE --putting x01 in a var to simplify l_test_var VARCHAR2(200) := apex_application.g_x01; l_return VARCHAR2(200); BEGIN -- a simplistic test IF LENGTH(l_test_var) BETWEEN 10 AND 20 THEN l_return := 'String is between 10 and 20'; END IF; --this will write l_return to the buffer, and the ajax callback will receive this htp.p(l_return); END;
And the code that I wrote above, which is javascript, would need to go where your current code is that binds to the onchange event. The result should be that, when a change is made to this element, an ajax request is made on the server. When the call is finished, it will be the value returned in the item you want.
-
Is there a way to match all columns in a table?
Oracle 11.1.0.7:
Is it possible to say match all columns in A table with table B? For example:
Table A
--
ID
name
Table B
--
ID
name
Is there a way to say matches all columns with a similar column in others in a select statement instead of making "where A.id = B.id and B.SID = b.name? I'm trying to write a script of comparison to check that replication is in effect doing the right thing.user628400 wrote:
Is there a way to say use 'Less', but exclude the column 'y' and 'z' comparison?Not without explicitly listing the columns that you want to compare in the different SELECT lists, no.
If it was something you wanted to do on a regular basis (looks like it's just a unique validation), you could potentially generate the statement LESS through dynamic SQL where you could easily exclude some columns. But it's more work that simply listing the column names in a static SQL statement, unless you plan to do on a regular basis.
Justin
-
How to remove columns from the table on the master 1-0?
I have an array of 96 columns with strings. I also have the array of int 96-elemets (mask) with 1 and 0.
What I want to do is to is to remove (or hide - but I read that it is not possible) all the columns with index corresponding to 0 in the mask table.
example:
columns in the table
1 2 3 4 5
mask
0 1 0 0 1
I want to remove the columns 1, 3 and 4 and leave only 2 and 5 in my table.
How can I do?
If I create loop for with i as the index of the column, when I do DeleteTableColumns() columns number decreases, and I get an error of range out of
Or do I have an option to hide the unnecessary columns (not set their width to 1, it's very ugly-looking)?
Please help me (())
Hello rovnyart!
1. removal of columns in the table:
I suspect that the reason why you get the out-of-range error is due to fact that in your loop, you delete the columns in the table, you'll eventually end up by referring to a column that no longer exists, because the other columns before it have been deleted. While you remove each column of your table in the loop for example, the column index number will move, because you deleted the other columns in front of her.
To resolve this, even if you delete a column in your loop, make sure that you take also into account that the index of the column is moved because of the removed columns.
2 hide columns in table:
You can use the ATTR_COLUMN_VISIBLE attribute to hide columns in the table:
http://zone.NI.com/reference/en-XX/help/370051Y-01/CVI/uiref/cviattrcolumnvisible_column/
3 alternatives:
Note that another alternative would also use a tree instead, control as the tree control also supports the hidable columns:
http://forums.NI.com/T5/LabWindows-CVI/table-hide-column/TD-p/569773
Best regards!
-Johannes
-
Hello! I have a problem with my data - I get in a wide range of 1 x 1000, but it's the repeated measures, each taking about 500 data points. I want to break this table for this data string start a new column in my table every 500 points given. I don't know how to do it-please help!
datacompiler100 wrote:
Hey thanks for the sponsor and the first off I must apologize for the State, I am attaching my VI. I put the part of the VI that I am working on (my team has access, so didn't post everything here) and also attached the data file (when just written in a spreadsheet file, not through the attached VI). I want to convert the long row of data and then start a new column every 50, 100, 5 points (user-defined).
Using the data from the file, you can reshape everything simply (as you already!), followed by transposition (since you want columns instead of rows). 2D arrays must always be rectangular, so the last column is filled with zeros if necessary. Is that what you want?
Of course if you try to add a new column in a file, that will not work. You can only add lines in an existing file because of the way the data is organized. To add columns, the entire file must be read, intertwined and all re-written new data in the file.
Maybe you are looking for
-
Documents and data on an iPhone, my phone is full of these
Documents and data on an iPhone, my phone is full of these
-
Ready remote NAS simply stopped to show my files
I've been using ReadyNAS Remote for years on my Android phone and an iPad - now it connects, or so it seems, but I show nothing - no directory structure, no file - it just stopped working. I reinstalled software/applications on both devices - NOTHING
-
HP pavilion dm4-2165dx: I forgot power on password in my laptop HP pavilion dm4-2165dx
I use power on password in my laptop. All of a sudden I am not able to connect. Its saying the power on password is wrong. Access denied. Please let us know how to reset. I myself after the code after entering three times wrong. The code is 86892078.
-
I want to learn installation.
-
Just installed C7180 All In One Printer on a Mac under OS 10.9.4. Scans OK and saved on the desktop. The scan to send the opening, I have just a spare page horizontal black and white lines. Any help gratefully received.