Only get Users that match all Links

Seemingly a very simple problem, but I can't seem to figure it out.
Table below is a table that holds UserId' s and LinkId's.
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'm looking for a query in which I can plug a List of LinkId's that outputs only users that have a relationship with ALL LinkId's provided.
In this example you may assume that the List is equal to (1, 2), but you can't make any assumptions about the size of the list, other than size != 0.
The query to find users that match ANY of the provided LinkId's 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 size > 0 list 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                  
In 11g here is a different way using UNPIVOT to build the list of Link IDs.  This may be less cumbersome than a long UNION ALL list.
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                  

Similar Messages

  • I have a iPad were I have opened I tunes match ect linked to my pc I have since found my old ipod classic which I have loads of music on but that was all linked to a mac which I don't have anymore, is there anyway I can sync them both

    I have a iPad were I have opened I tunes match ect linked to my pc I have since found my old ipod classic which I have loads of music on but that was all linked to a mac which I don't have anymore, is there anyway I can sync them both without loosing my music, if I plug my ipod into PC it won't read it

    You need to transfer the music from your iPod on to your iTunes library on your PC, since that is where you are currently syncing and where you are signed into iTunes Match.  It doesn't matter that you were previously syncing it with a Mac, and you won't need to reinstall iTunes on your PC.  But you will have to use 3rd party software such as Touch Copy to transfer any music not purchased from the iTunes store from your iPod to your iTunes library.  Here's another guide on this, which is shoter and you may find easier to follow: Syncing to a "New" Computer or replacing a "crashed" Hard Drive.  Also, if you're using iTunes 11, go to View>Show Sidebar.  This will make it easier to follow along with these guides.

  • A php search engine that only shows results that match entire serch string

    I have set up a dreamweaver search engine through php and a fulltext search (WHERE MATCH (....) AGAINST (...). However, when someone inputs more than one word into the search form, the search engine churns out results that only have one of those words. How do I get it to only show results that have all the search string words inside? (or, at least, how do I get those results to show up at the top?)
    I have seen some advice (here) that uses php code to process the search query, divide up the words, and place a BOOLEAN '+' between each of the words. By doing this, the search engine will only show results that fully match all the terms.
    My problem is that I do not know how to put this code into my Dreamweaver-created code.
    My dreamweaver created code:
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $form_rsSearch = "-1";
    if (isset($_get['search'])) {
      $form_rsSearch = $_get['search'];
    mysql_select_db($database_dataConnect, $dataConnect);
    $query_rsSearch = sprintf("SELECT title, content FROM encyclopedia WHERE MATCH (title, content) AGAINST (%s)", GetSQLValueString($form_rsSearch, "text"));
    $rsSearch = mysql_query($query_rsSearch, $dataConnect) or die(mysql_error());
    $row_rsSearch = mysql_fetch_assoc($rsSearch);
    $totalRows_rsSearch = mysql_num_rows($rsSearch);
    $input_rsSearchResults = "-1";
    if (isset($_GET['search'])) {
      $input_rsSearchResults = $_GET['search'];
    mysql_select_db($database_EMdataConnect, $dataConnect);
    $query_rsSearchResults = sprintf("SELECT title, content FROM encyclopedia WHERE MATCH(title, content) AGAINST(%s)", GetSQLValueString($input_rsSearchResults, "text"));
    $rsSearchResults = mysql_query($query_rsSearchResults, $dataConnect) or die(mysql_error());
    $row_rsSearchResults = mysql_fetch_assoc($rsSearchResults);
    ?>
    and the code the website (link above) gives is:
    function search(String $search_string) {
         //strip Boolean search characters out of search string
         $search_string = string_replace($search_string,"+","");
         $search_string = string_replace($search_string,"-","");
         $search_string = string_replace($search_string,"*","");
         //split the search string up into an array of words
         Array $tokenized_search = split($search_string, " ");
         //init an empty final search string
         String $processed_search = "";
         //for each word in the search, wrap it
         //with an + and * character and then append
         //it to the processed_search variable
         foreach($tokenized_search as $token) {
              $processed_search+="+"+$token+"* ";
         //build the sql for the query and query the DB
         String $db_query = "select id, description
              from product_descriptions
              where MATCH(description)
              AGAINST ('"+$processed_search+"' IN BOOLEAN MODE)";
         Array results = execute_database_query($db_query);
         return results;
    If anyone can instruct me on the correct way to go about this, I would be very much obliged.
    Thank you,
    YWSW

    Don't use the Search bar, type the address in the Location bar.

  • We are unable to find a user that matches the Rep.ID and Password you have entered. Please verify and try again. work on IE but now Firefox

    We are unable to find a user that matches the Rep.ID and Password you have entered.
    Please verify and try again.
    I get this error when trying to access my Wild Tree web site
    http://resources.wildtree.com/MyWildtree/RepLogin.aspx?ReturnUrl=%2fmywildtree%2fMain.aspx
    I can log in just fine to the main page, but then they make you log in again as you go deeper into the site for Security reasons. But when I log in the 2nd time, I get the above error. Help

    This can be caused by corrupted cookies or cookies that are blocked (check the permissions on the about:permissions page).
    *https://support.mozilla.org/kb/fix-login-issues-on-websites-require-passwords
    Note that you may have to enable third-party cookies for that domain or for visited sites.
    *Tools > Options > Privacy > Firefox will: "Use custom settings for history"
    Clear the cache and cookies only from websites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    If clearing cookies doesn't work then it is possible that the <i>cookies.sqlite</i> file that stores the cookies is corrupted.
    Rename (or delete) <b>cookies.sqlite</b> (cookies.sqlite.old) and delete other present cookies files like <b>cookies.sqlite-journal</b> in the Firefox profile folder in case the file cookies.sqlite got corrupted.
    *http://kb.mozillazine.org/Cookies
    *https://support.mozilla.org/kb/Deleting+cookies

  • Can't sync my phone after updating. Only getting message that I need to restore (which I have done several times now)

    I, sadly like so many others, updated to the bug filled 5.0.1 and my phone had an error. I got the little link to iTunes and nothing else on my phone after it shut down. Once I did that I have an option to set up as a new phone or restore to my last sync (earlier in the day). I have run the restore three times and each time the phone goes through and shuts down. When it turns back on I have signal, 3G, contacts, text history, calendars, and photos as well as a few apps. Most of my apps are gone and my music library is empty. When I link the phone back to sync I get the same message as initially, that I need to set up as a new phone or restore.
    I don't have time to go to an Apple Store to get this worked on and I'm pretty disgusted that Apple has been virtually silent on this matter. Most of the answers I have seen to the various problems people are reporting are coming from other users.
    If anyone out there has an idea for me to try, please share. Apple if you're reading this you NEED to do something ASAP because I was planning on getting a new phone after the holidays but if I have to get one now it may not be another iPhone (which this is my third version of over the past 4 years) as I'm not spending the money on myself right before the holiday so it'll be free/discounted phone with updated contract for me, and we know Apple doesn't do that!!

    iTunes places the .ipsw file here:
    OSX:
    ~/Library/iTunes/iPhone Software Updates
    XP:
    C:\Documents and Settings\[username]\Application Data\Apple Computer\iTunes\iPhone Software Updates
    7 &Vista:
    C:\Users\[username]\AppData\Roaming\Apple Computer\iTunes\iPhone Software Updates
    Find and delete any and all .ipsw files on your computer. There should only be one, but delete all that you find. Next, disable ALL firewalls & security software on your computer. Connect your phone, iTunes running & restore from backup. Follow this by syncing your content back to your phone.
    This will force iTunes to re-download the .ipsw file, as I suspect yours is corrupt.

  • Getting user-supplied data for links to remote website

    Hi,
    I want to certify a enterprise portal business package that should be fairly easy. This is my first experience using SAP or doing an integration and this forum and the documentation is my only access to information. There are no experts here...yet.
    Anyway, the only thing I need to do for the portal integration is to display some links to our .NET web application. When a user selects one of the links, the associated web page should display in the right pane of the portal.
    My questions are this:
    Is displaying the webpage in the right pane of the portal OK? Are there any issues I need to consider when displaying the webpage content, such as the look of the page? (I would like to display the page exactly as it is displayed if one were to use a web browser to view it if that is OK).
    The .NET application runs on IIS. Is it permitted to run this on the same machine as the SAP server?
    What would be the best technique to get information about where my .NET web application is running, such as host and port number? When one installs the business package, they must either be asked to enter the location of the remote web server, or maybe the information can be retrieved from a configuration file. (?)
    Lastly, is it OK to create the links using the URL iView or should I use Visual Studio to create the links then create a PAR file?
    Thank you very much for your help

    Hi,
    If I undestand correctly you are trying for PBNW (Powered by Netweaver certification ).
    In that case they don't accept url iViews.
    Peronalisation and SSO are pre requiste for the certification .So, you may have to develop .Net iviews for your application.
    Thanks,
    Abdul raheem S

  • For weeks we only get inbox, minutes ago all restored, now back,helpk

    Inbox is the only folder that has been available for a number of weeks. Then, 30 minutes ago when I started the computer, there they were, all back: sent, drafts, my local folders, etc. Before we knew it, inbox became the only visual folder again. This has never happened to us before.

    Hi
    You should ask your relative to physically take the iPhone to the store rather than shipping it because as diesel vdub has said:
    "No Apple store will accept an iPhone shipped to them"
    All you have to do is safely pack and ship your iPhone from the Philppines to your California-based relative.
    HTH?
    Tony

  • Is there a way to create a pdf that preserves all links from the origional document?

    Hi,
    I have a new, rather large, pdf document I need to create. After discovering that adobe will not reliably convert hyperlinks from an office document, I need a new strategy. Does anyone know of a program, other than office, that adobe will reliably convert the links in the origional document into links in the pdf? Or is there a different way to do this, other than adding links in adobe after I create the pdf?
    I have Windows 7, Office 2007, Acrobat Pro X, and IE 8 (I know... it's a work laptop)
    Thanks

    In iTunes, File>Print. Then select your options.

  • Filter "Other users" to only show schems that have objects

    I searched thru the forum, but didn't see this request anywhere. It would be nice to have a preference to only display "Other Users" who actually own objects in their schema.
    In TOAD, there's a preference like this under Schema Browser->Data. Their preferences are:
    * Show all users
    * Only show users that own objects
    * Only show users that own objects excluding Synonyms
    * Only show users that own objects excluding Synonyms and Temporary Tables
    This would be really useful for me, as our database has a ton of users that have no objects. :-)
    Thanks for a cool product that works on my Mac!
    --Leif                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    It is great to have this feature, but at our site it is VERY slow - so much so that I thought that SQL Developer had hung.
    I assume that when this option is selected, the query is doing something like select distinct owner from all_objects and when the option is not selected it is querying user_name from all_users?
    It takes only about a second to display our list of appoximately 1800 users (unsorted at the moment :( ) and it took 95 seconds to filter that list to the 235 users that have visible objects (we have ~ 240000 records in all_objects).
    On another point, selecting this option effectively removes an already saved filtered user if it doesn't have any available objects. This seems to include checking against schemas with availble objects when expanding the "Other Users" node, which now takes significantly longer than when this option is not set - taking 60 seconds to expand the node which is filtered to just eight schemas out of the 235 with available objects.
    Going back to the Other Users Filter to switch off this option appears to simply hang SQL Developer for the ~ 90 seconds that it takes to query the list of schemas with available objects.
    I don't know whether it is possible to do something about this sort of performance, but with the performance I am getting at the moment, I won't be using this functionality.

  • Cursor as Pointer Hand over ALL links?

    Looking to emulate what flash and browsers do for buttons, switch from the cursor to the pointer hand. It seems to happen to everything seen as a button but I need it to do that on all links. Suggestions? This is for an exe. presentation.
    Thanks

    just to chime in, this another "oops we did it again" by adobe.
    They claimed that flash was now used to build "applications" and in "applications" you don't get a pointer finger everytime you interact with a menu / button. So now the default behavior of interactive objects is to NOT show the pointer.
    They developed the original tv.adobe.com site using flash and it was a disaster. It was very bizarre and counter intuitive to interact with elements and not have the cursor change. The latest version of the site has been html-ized and all the ineractive elements now show the pointer. the site is better organized and a pleasure to use.
    It goes without saying that any interactive content in the context of a browser (99% of all flash deployment) should give you a pointer finger when you rollover. I guess they thought they could change a decade of user experience.
    For now you manually have to enable button mode when you want this "default" behavior. you could probably build an array of all your buttons and blast through to make the change... but its still work.

  • Best way to code to retrieve a field that matches one value

    Hello,
    Thanks for reading this post!
    I have a data set where users can be part of workgroups. I want to exclude any user that is part of workgroup 2 and 7, and only retrieve users that are solely part of workgroup 2.
    There can be users that are part of just workgroup 7 or other workgroups like 4, 5, 6 etc., but I only want users that have only workgroup 2 and no other workgroup.
    CREATE TABLE users
    ( user_id NUMBER(10)
    , user_lastname VARCHAR2 (50)
    , workgroup NUMBER(10)
    INSERT ALL
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (3, User_lastname3, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (4, User_lastname4, 7)
    I want to exclude any users that have both workgroups 2 and 7 and
    only retrieve users that have just 2. In this case I only want to retrieve user_id 3.
    Thanks!
    Edited by: dbarcell on Oct 8, 2011 11:44 AM
    Edited by: dbarcell on Oct 8, 2011 11:48 AM
    Edited by: dbarcell on Oct 8, 2011 11:51 AM

    dbarcell wrote:
    Hello,
    Thanks for reading this post!
    I have a data set where users can be part of workgroups. I want to exclude any user that is part of workgroup 2 and 7, and only retrieve users that are solely part of workgroup 2.
    There can be users that are part of just workgroup 7 or other workgroups like 4, 5, 6 etc., but I only want users that have only workgroup 2 and no other workgroup.
    CREATE TABLE users
    ( user_id NUMBER(10)
    , user_lastname VARCHAR2 (50)
    , workgroup NUMBER(10)
    INSERT ALL
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (3, User_lastname3, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (4, User_lastname4, 7)
    I want to exclude any users that have both workgroups 2 and 7 and
    only retrieve users that have just 2. In this case I only want to retrieve user_id 3.
    Thanks!
    Edited by: dbarcell on Oct 8, 2011 11:44 AM
    Edited by: dbarcell on Oct 8, 2011 11:48 AM
    Edited by: dbarcell on Oct 8, 2011 11:51 AMSQL> CREATE TABLE users
    ( user_id NUMBER(10)
    , user_lastname VARCHAR2 (50)
    , workgroup NUMBER(10)
    INSERT ALL
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (3, User_lastname3, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (4, User_lastname4, 7) 2 3 4 5
    Table created.
    SQL> SQL> 2 3 4 5 6 7 ;
    INTO users(user_id, user_lastname, workgroup) VALUES (4, User_lastname4, 7)
    ERROR at line 7:
    ORA-00928: missing SELECT keyword
    test data is FUBAR!

  • Is there a way to 'Force all Links to be opened in New Tabs ' like Maxthon browser?

    Is there a way to get Firefox to 'Force all Links to be opened in New Tabs, like Maxthon browser does ? I really like this Maxthon feature but hate Maxthon as it has always has and continues to lock up all the time (what a pain!!)
    Hoping Firefox can do this. By the way I know if you right click a link and ask for it to open in a new tab it will. I want it to be automatic.
    Thank you

    Question already asked and answered.
    I gave an AppleScript and an other helper described a scheme relying upon standard features.
    Yvan KOENIG (VALLAURIS, France) jeudi 21 juillet 2011 23:08:28
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please :
    Search for questions similar to your own
    before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • HT1420 Trying to get latest version of Itunes and keep getting message that Apple Mobile Devices failed to start, do I have authorization. I am only user.  I have uninstalled old version of ITunes, becuase I kept getting errors. What do i do?

    Last time I opened ITunes, was told I did not have latest version and proceeded to download new version.  As it was loaded, keep getting message that Apple Mobile Devices failed to start, verify that I have sufficient privileges to start system services.  I am the only user on the computer and in household. I have tried installing several timees and keep getting same message.
    What should I do?

    Hey CarleneS,
    First, I would try the steps in here:
    How to restart the Apple Mobile Device Service (AMDS) on Windows
    http://support.apple.com/kb/TS1567
    If you end up having to remove and reinstall iTunes, make sure you follow all of the steps in this link:
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    http://support.apple.com/kb/HT1923
    This section contains information that might help your situation, as the order and manner which you uninstall has an effect on the outcome:
    Use the Control Panel to uninstall iTunes and related software components in the following order and then restart your computer:
    iTunes
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support (iTunes 9 or later)
    Important: Uninstalling these components in a different order, or only uninstalling some of these components may have unintended affects.
    Let us know if following that article and uninstalling those components in that order helped the situation.
    Welcome to Apple Support Communities!
    Regards,
    Delgadoh

  • I recently purchased Music Match, but all my non itunes music is on my ipad.  When i turn on music match in the settings screen on my ipad i get a message that says all my music will be erased.  How do I get music match to match what is there?

    I have all my music on my ipad and icloud.  I don't have itunes installed on a PC or MAC.  I recently purchased Music Match, but all my non itunes music is on my ipad.  When i turn on music match in the settings screen on my ipad i get a message that says all my music will be erased.  How do I get music match to match what is there rather than erase it? 

    Killerfinch wrote:
    My new yahoo account nestles comfortably in iCloud on the mine iPad.
    No, your Yahoo account is not in iCloud (which only handles iCloud mail), it is in Yahoo, and the Yahoo mail account is on your iPad.
    But the MacBook Pro will have none of it! I write this question now as I fear that I will be totally demented very soon and unable to formulate my thoughts clearly!
    Get the correct settings for your account from Yahoo and set it up manually.
    By the way, I also find the "password" issue problematical. It seems Apple want my Apple password rather than my eMail password. All very confusing.
    That would depend on what you are trying to do.

  • If my iphone, ipad, MAC and macbook pro are all linked, and then I upgrade only my phone to iOS 7.0, does that have an effect on my calendar, etc.  It doesn't seem to be showing the same data it was before the update.  Lost lot of info from calendar.

    If my iphone, ipad, MAC and macbook pro are all linked, and then I upgrade only my ipone to IOS 7.0, does that have an effect on the linking to my other MAC products.  It seems my calendar has lost a lot of information since the upgrade.

    If you purchased Lion for your iMac, just log into the Mac App Store from your MacBook using the Apple ID under which you purchased Lion and go to the Purchases page. You will be able to download and install Lion there. 
    searching the internet i found a link to upgrtade to 10.7
    The only place you get get Lion is from the Mac App Store. If you found some other site, that was an illegal copy and almost certainly tied to someone else's Apple ID and hence unusable by you. If the link was just to the Mac App Store, see above.
    As to the problem with synchronization to iCloud, that's not a 10.6 question, so I'd suggest you take up that specific issue in either the Lion or iCloud forums, providing full details, and someone there can probably help you sort things out.
    Regards.

Maybe you are looking for

  • MRP Area and SA Schedule Lines

    Hello All,     We are looking at using MRP Areas and noticed it can not be turned off once on (ECC 5.0).  Given that, is the following true with reference to schedule agreements: - Will seperate schedule lines be created for each MRP Area (same mater

  • How to load 2 xml galleries in single function loop.

    how to load 2 xml galleries in single function loop. my function is-------- var myGalleryXML = new XML(); myGalleryXML.ignoreWhite = true; myGalleryXML.load("gallery.xml"); function callThumbs()     _root.createEmptyMovieClip("wall",_root.getNextHigh

  • PSE 10 one program for two computers

    Hello; my question is, it possible to use my PSE 10 that is installed on my PC and use it on my laptop via a home network ? downloading the program onto my PC is not an option. I once had it installed I had to replace my drive thus using the two allo

  • SPnego Mapping module error

    Hi gurus, please help me i am getting the below error Policy Configurations and created as com.sun.security.jgss.accept Login Module Stack and in that i am able to add the module krb5loginmodule com.sun.security.auth.module.Krb5LoginModule but when i

  • Why does wallpaper in iOS have to be enlarged and cannot be size of photos

    Why does wallpaper in iOS have to be enlarged and cannot be size of photos?