Get only the users that correspond to all the links
Apparently a very simple problem, but I can't seem to understand.
Below is a table that contains the user's and LinkId name.
CREATE TABLE UserLink (UserId NUMBER, LinkId NUMBER ); ALTER TABLE UserLink ADD PRIMARY KEY (UserId, LinkId); INSERT INTO UserLink VALUES (1, 1); INSERT INTO UserLink VALUES (1, 2); INSERT INTO UserLink VALUES (3, 1); INSERT INTO UserLink VALUES (4, 1);
I am looking for a query in which I can plug a LinkId list that shows only users who have a relationship with of all THE LinkId condition.
In this example, you can assume that the list is equal to (1, 2), but you can not make all the assumptions concerning the size of the list, except the size! = 0.
The query to search for users that match to THE provided LinkId is quite simple:
SELECT UserId FROM UserLink WHERE LinkId IN (1,2)
The correct query should output:
USERID ------ 1
And it should work for any > 0 see size of values.
Here's one way:
with ID_LIST as (select 1 LINKID from DUAL union all select 2 from DUAL) select distinct USERID from USERLINK a where not exists ( select LINKID from ID_LIST minus select B.LINKID from USERLINK B where B.USERID=a.USERID ) ;
11 g here's a different way using UNPIVOT to generate the list of link IDS. It is perhaps less bulky than a long list of UNION all.
with ID_LIST as (select 1 a,2 b from DUAL) select distinct USERID from USERLINK a where not exists ( select LINKID from ID_LIST UNPIVOT (LINKID for COL in(a,b)) minus select B.LINKID from USERLINK B where B.USERID=a.USERID ) ;
Tags: Database
Similar Questions
-
Hello world
Suppose I have a table emp that has thousands of lines of data. In this table of employees receive wages between 1000-10000.
Now I have to get only the employees whose salary is equal.
for example
empNo empName sal
----------- ------------- ---------
1 ram 5000
2 5000 Shyam
3 1000 Dilip
4 deepak 2000
5 sisi 1000
6 1000 Priya
so now...
Now without using ' select * from emp where Sal IN (5000,1000). "How can I get these employees with the same salary?
SELECT *.
EMP e1
WHERE EXISTS (SELECT 99 FROM emp e2 WHERE e2.sal = e1.sal AND e2.empno! = e1.empno)
or maybe
SELECT *.
WCP
WHERE sal IN (SELECT sal FROM emp GROUP BY sal HAVING COUNT (*) > 1)
-
Get only the Apple logo on my iPhone 5 s
I get only the Apple logo on the iPhone 5 s. Tried to update and restore through iTunes but it would not be completed that.
Hello
On the computer, make sure that iTunes is up to date.
Mac
- Open iTunes.
- In the MenuBar at the top of your computer screen, choose iTunes > check for the updates.
- Follow the prompts to install the latest version.
Windows
- Open iTunes.
- In the MenuBar at the top of the iTunes window, choose Help > check for updates. Learn what to do If you see not the menu bar.
- Follow the prompts to install the latest version.
-
When I launch Firefox, I get only the bottom of my browser in the Firefox window. I have the normal window for 1 second, but it changes in the background window only. So, without the toolbar or navigation. I have already reinstalled it, but it does not solve the problem.
Hello jonson00, please follow the troubleshooting steps in Firefox opens with a white or transparent window. If this solves the problem, it would be also interesting including the extension has a problem in your case. Thank you!
-
I've lost the main screen for photoshop! I don't know what I did, but now when I open photoshop, I get only the tool bar at the top and a little on the sides. How can I go back to the normal screen?
Hi renaeb,
Would you go to the Windows menu in Photoshop and check the option framework application from the drop-down list.
Concerning
Sarika
-
Uninstalled Potoshop Elements 7 on my old PC. Tried to install on the new PC, you get only "the code you entered is invalid." How can I install on my new PC, it's bought and paid for and if I look at my account, it is there. Cannot find any e-mailadress support. What should I do?
Error "serial number is not valid for this product". Creative Suite
http://helpx.Adobe.com/Creative-Suite/KB/error-serial-number-valid-product.html
-
How to get only the whole ticks on a horizontal axis of a graph?
Hello
Could someone help me find oout how to get only the whole ticks on a horizontal axis of a graph?
When I have a number less than 5, I get like 0, 0.2, 0.4 ticks... while I want it to be 0, 1, 2...
Thank you
Yannhealer
Try this Clara. Put this inbetween your chart labels:
Set the interval to meet your needs of 'tick '.
-
I followed the advice and imported IE Favorites, but only the first two files have met. How can I get all THE files across please?
Wow. I think I will like Firefox if the aid is so easily available, quick and as good as this. Fixed right away
Thank you very much
Kevod -
Can we get only the number of SQL varchar column?
Hi all
I have a table as below.
CREATE TABLE TEST21 (COLUMN-NAME VARCHAR2 (30));
INSERT INTO TEST21 VALUES ('23');
INSERT INTO TEST21 VALUES ('32569');
INSERT INTO TEST21 VALUES ('JAGAN");
INSERT INTO TEST21 VALUES ('12JAGAN2');
Now I NEED the DATA that contains only the digit.
SELECT * FROM TEST21 where... (PROPOSAL BY CONDITION);
COLUMN-NAME
-----------
23
32569
So is it possible?
Hello
select * from test21 where regexp_instr(col_name,'[[:alpha:]]') = 0 ; COL_NAME ------------------------------ 23 32569
-
analysis to get only the first node of the XML.
Hello
I'm trying to parse the following xml tag. I want only the first node in the ORDER_PAYMENT_DETAIL element, and then the other node element.
I would appreciate your help.
---
< ORDER_PAYMENTS >
< ORDER_PAYMENT >
< ORDER_NO > 20000404 < / ORDER_NO >
< PAYMENT_METHOD_ID > 5 < / PAYMENT_METHOD_ID >
< PAYMENT_SEQ_NO > 0 < / PAYMENT_SEQ_NO >
< CHARGE_AMOUNT > 50 < / CHARGE_AMOUNT >
USD < CHARGE_CURRENCY > < / CHARGE_CURRENCY >
< ORDER_PAYMENT_DETAILS >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 2 < / ATTRIBUTE_ID >
Test1 < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 1 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > CC < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 3 < / ATTRIBUTE_ID >
< > 4222222222222 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 4 < / ATTRIBUTE_ID >
< > 01 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 5 < / ATTRIBUTE_ID >
< > 2012 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 10 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > AP53-7457490 < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 11 ATTRIBUTE_ID < / ATTRIBUTE_ID >
ID575754W34623525SDT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 12 ATTRIBUTE_ID < / ATTRIBUTE_ID >
KEY111222333444555FSDRT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 2 < / ATTRIBUTE_ID >
Test2 < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 1 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > CC < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 3 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > 4444444444444448 < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 4 < / ATTRIBUTE_ID >
< > 02 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 5 < / ATTRIBUTE_ID >
< > 2013 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 10 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > AP53-7457490 < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 11 ATTRIBUTE_ID < / ATTRIBUTE_ID >
ID575754W34623525SDT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 12 ATTRIBUTE_ID < / ATTRIBUTE_ID >
KEY111222333444555FSDRT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< / ORDER_PAYMENT_DETAILS >
< / ORDER_PAYMENT >
< ORDER_PAYMENT >
< ORDER_NO > 20000404 < / ORDER_NO >
< PAYMENT_METHOD_ID > 1 < / PAYMENT_METHOD_ID >
< PAYMENT_SEQ_NO > 1 < / PAYMENT_SEQ_NO >
< CHARGE_AMOUNT > 10.47 < / CHARGE_AMOUNT >
USD < CHARGE_CURRENCY > < / CHARGE_CURRENCY >
< ORDER_PAYMENT_DETAILS >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 2 < / ATTRIBUTE_ID >
Test1 < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 1 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > CC < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 3 < / ATTRIBUTE_ID >
< > 4222222222222 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 4 < / ATTRIBUTE_ID >
< > 01 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 5 < / ATTRIBUTE_ID >
< > 2012 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 10 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > AP53-7457490 < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 11 ATTRIBUTE_ID < / ATTRIBUTE_ID >
ID575754W34623525SDT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 12 ATTRIBUTE_ID < / ATTRIBUTE_ID >
KEY111222333444555FSDRT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 2 < / ATTRIBUTE_ID >
Test2 < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 1 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > CC < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 3 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > 4444444444444448 < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 4 < / ATTRIBUTE_ID >
< > 02 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 5 < / ATTRIBUTE_ID >
< > 2013 ATTRIBUTE_VALUE < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< ATTRIBUTE_ID > 10 < / ATTRIBUTE_ID >
< ATTRIBUTE_VALUE > AP53-7457490 < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 11 ATTRIBUTE_ID < / ATTRIBUTE_ID >
ID575754W34623525SDT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< ORDER_PAYMENT_DETAIL >
< > 12 ATTRIBUTE_ID < / ATTRIBUTE_ID >
KEY111222333444555FSDRT < ATTRIBUTE_VALUE > < / ATTRIBUTE_VALUE >
< / ORDER_PAYMENT_DETAIL >
< / ORDER_PAYMENT_DETAILS >
< / ORDER_PAYMENT >
< / ORDER_PAYMENTS >Do you mean the full xml, excluding all the ORDER_PAYMENT_DETAIL elements, but the first?
SQL> select deletexml(colx,'//ORDER_PAYMENT_DETAIL[position()>1]').extract('/*') 2 from tabx; DELETEXML(X,'//ORDER_PAYMENT_DETAIL[POSITION()>1]').EXTRACT('/*') -------------------------------------------------------------------------------
20000404 5 0 50 USD 2 test1 20000404 1 1 10.47 USD 2 test1 Note that the ".extract('/*')" is there only for the formatting...
Max
http://oracleitalia.WordPress.com -
Get only the alphanumeric column numbers
Hi all
How can I get to the numbers in the alphanumeric column?
I use the following question for this.
with tab as)
Select 25 - Abc' key1 of union double all the
Select 233 - xyz' key1 of union double all the
Select 'x23A' key1 in union double all the
Select 91 w-2-dd-2' double key1
)
tab, select regexp_substr(key1,'[[:digit:]]+')
But here the last row (91-w-2-dd-2) returns only two first digits (91). But I need 9122.
My version of oracle's 10g release 2.
Thank you
SujnanThis can do
Processing ... with tab as ( select '25-Abc' key1 from dual union all select '233-xyz' key1 from dual union all select 'x23A' key1 from dual union all select '91-w-2-dd-2' key1 from dual ) select regexp_replace(key1,'[^0-9]+','') from tab Query finished, retrieving results... REGEXP_REPLACE(KEY1,'[^0-9]+','') -------------------------------------------------------------------------------- 25 233 23 9122 4 row(s) retrieved
Alessandro Bye
-
Hello
I use apex 5.0 with 12 c db,
In a tabular presentation, there is an element of the checkbox. How do I know that this point be changed so I can update only the changed fields.
Best regards
Hello
Apex$ row_selector try it please see
https://docs.Oracle.com/database/121/HTMDB/concept_sub.htm#CHDGJFII
-
How to get only the year of a date?
I try to shoot only the year of a date and does not know how this can be done. I tried the SUBSTR function but its does not not how I think. What I want to do, it is write a condition indicating the year of birth of point = current year minus 23, I have a calc than the figures of the age of the difference in the date of birth and the current year, but I'd really like to just write a condition based just a years. Is this possible?Hello
SUBSTR only works on a string. To extract parts of a date, you must use the TO_CHAR command.For the year, you would use this: TO_CHAR (the_date, 'YYYY')
To_char takes 2 switches, the date to be handled and the part to be extracted, with the portion between apostrophes.
Once you get used to manipulate dates as this other common areas are: DD - extracts the day of the month, MY snippet code to 3 characters for the month.
For example, you can use this: TO_CHAR(sysdate,'DD-MON-YYYY') and it converts the current date, June 7, 2012 to June 7, 2012
Hope this helps
Best wishes
Michael -
Hello
I have a table as below
emp_id (integer)
id_est (integer)
dt_est (date)
for each emp_id I have several id_est with several dt_est... as below
emp_id id_est dt_est
1 1 10-01 - 2009
1 2 2009 - 01 - 13
2 3 2009 - 01 - 10
2 4 2009 - 01 - 12
2 5 2009 - 01 - 14
3 6 2009 - 01 - 12
4 7 2009 - 01 - 15
5 8 2009 - 01 - 17
5 9 2009 - 01 - 19
I would get just the news lines function date each emp_id, so my result should be as below
emp_id id_est dt_est
1 2 2009 - 01 - 13
2 5 2009 - 01 - 14
3 6 2009 - 01 - 12
4 7 2009 - 01 - 15
5 9 2009 - 01 - 19
How I do that?
Thank youHello
Try this code.
Salim cordially.
SELECT id_emp, MAX (id_est), MAX (dt_est) FROM t GROUP BY id_emp
-
When only the url is displayed in the address list, it is much cleaner and easier to read, as in earlier versions.
Add code to the file userChrome.css below default @namespace.
@namespace url("https://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */ .ac-title-box { display:none !important; }
The file userChrome.css (UI) customization and userContent.css (Web sites) are located in the folder of chrome in the Firefox profile folder.
- http://KB.mozillazine.org/Editing_configuration
- http://KB.mozillazine.org/Editing_configuration/troubleshooting
See also:
Maybe you are looking for
-
Freeze after update 33.0.3
I just updated Firefox 33.0.3 and it crashes whenever I try to go to any Web site, but my homepage. It freezes the computer and the only way to resolve is to manually turn off the computer. Can not even the Manager of the upcoming tasks using the com
-
HP xw6600: How does your match at Passmark Software HP workstation?
[url = http://www.passmark.com/baselines/V9/display.php?id=67168262348] [img] http://www.passmark.com/baselines/V9/images/67168262348.png [line] [url]
-
I bought an iphone used several years ago... When updating with the new iOS 7.1.2 recently, he was locked with previous apple owners account. its now useless. I didn't know all these crappy activation locks and all.now I have no idea How can I find m
-
Invoke a problems of default browser with the code 4.5 session
Hello, I uses this simple code to create an icon on the desktop, and then point to an internal URL by invoking the browser of BES. http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/796557/800332/800440/... This worked gre
-
Hi, I know that is neither right, am I on v701 with 32 MB of memory, and PIX is now in a reboot loop. I can get to analyze mode, knowledge the downgrade from monitor mode. Or how I could get out of the loop. If I get to the command line I can downgra