Subquery to get results on either side of query result

I need to get room numbers that are 2 above and 2 below the
authenticated user's room number. I pretty much knew the attached
code wouldn't work, but it's the idea of what I want to do. The top
part of the query gives me the authenticated person's room number,
then I need to grab all room numbers that are between 2 on either
side of him/her. In other words, if user is in room 110, I need all
folks in room 108, 109, 111, 112 (and disclude 110). I'm just not
skilled enough yet to get this query correct. It is MySQL if that
makes a difference.

as Dan has pointed out, i had a mistake in my reply (which i
blame on
trying to post reply before having my first cup of coffee).
what i meant to say is, even though you query only one table,
you have
it aliased twice, as two different tables, and thus you need
to use
tablealias.columnname in your SELECT clause, and probably for
all
columns you select, not just username column which mysql
complains about
at the moment.
so your SELECT clause should look something like:
SELECT p1.username, p1.fname, p1.lname, p1.dorm, p2.room
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Similar Messages

  • I have an imac, intel 2 duo. OS 10.6.8. Suddenly my desktop is showing two thin lines running from top to bottom, each about 2" from either side. How can I get rid of them?

    I have an imac, intel 2 duo. OS 10.6.8. Suddenly my desktop is showing two thin lines running from top to bottom, each about 2" from either side. How can I get rid ofthem?

    That's strange...
    Resetting PRAM might help: http://docs.info.apple.com/article.html?artnum=2238
    If that doesn't help, I'd recommend contacting AppleCare.
    it seem to be lcd problem

  • When I create a new chapter sometimes I get the chapter number with bullets on either side and sometimes I don't. I want to be constant. How do I consistently create bullets on both sides of the Chapter Number?

    How do I create bullets on both sides of the Chapter Number?  eg. Chapter One with bullets on either side.

    K T
    I originally started with a template but just erased all the content and built the book using blank pages. Sometimes when I add a chapter it comes up  like the example below or it could come up without the bullets. For the life of me, I don't understand why.
    Van Hunter
    • Chapter Eight •    

  • Pagination with 10 pages - 5 either side

    Hi all,
    I'm trying to get some pagination to my results page.
    I would like the navigation links to only show 5 pages on either side of the current page.
    For example if I have 40 pages in total:
    Page 1 shows:
    *1* _2_ _3_ _4_ _5_ _6_ _7_ _8_ _9_ _10_ [_Last_] Next
    Page 18 shows:
    [_First_] _14_ _15_ _16_ _17_ *18* _19_ _20_ _21_ _22_ _23_ [_Last_] Next
    Currently I have all the page links (1-40 echoed) by using this tutorial:
    http://www.phpbuilder.com/tips/item.php?id=2
    Hope someone can help as I'm completed stumped!

    If my very quick scan of the article was correct you'll need to change the loop start and end values in this part of the code:
    // Now loop through the pages to create numbered links
    // ex. 1 2 3 4 5 NEXT >>
    for ($i=1;$i<=$pages;$i++) {
         // Check if on current page
         if (($offset/$limit) == ($i-1)) { Change the loop bounds 1 and $pages. You'll need to do some maths to work out the current page number, and then add and subtract 5 for the start and end. Make sure not to go past the start or end of the set of pages. Good luck.

  • Why am I being told that a JPEG file that I made changes to in Photoshop 6 (CS6) can't be saved?  The message I get says that either the file is locked and I don't have permission to execute this or another program is using this file.

    i recently purchased a 21.5 iMac with Yosemite (10.10.1) and was disappointed to discover that my CS6 programs are not functioning correctly.  I am unable to use the "Save As" command  when making changes to a JPEG file in Photoshop.  The message I get says that either another program is using the file or it is locked and I don't have permission to execute that command.  I'm experiencing a similar problem in Bridge when trying to move an unwanted file to the Trash.  Again, I get a message telling me that i don't have permission to do this.  Lastly, I'm unable to open any Camera Raw files.  Any suggestions?  I had no problems with the Mavericks OS on my old iMac and although it's much slower, I'm tempted to go back to using my old iMac.  At this point, I feel as if I've just wasted $2300+ (tax included). 

    Back up all data before proceeding.
    This procedure will unlock all your user files (not system files) and reset their ownership, permissions, and access controls to the default. If you've intentionally set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it, but you do need to follow the instructions below.
    Step 1
    If you have more than one user, and the one in question is not an administrator, then go to Step 2.
    Triple-click anywhere in the following line on this page to select it:
    sudo find ~ $TMPDIR.. -exec chflags -h nouchg,nouappnd,noschg,nosappnd {} + -exec chown -h $UID {} + -exec chmod +rw {} + -exec chmod -h -N {} + -type d -exec chmod -h +x {} + 2>&-
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    Paste into the Terminal window by pressing command-V. I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting.
    You'll be prompted for your login password, which won't be displayed when you type it. Type carefully and then press return. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The command may take several minutes to run, depending on how many files you have. Wait for a new line ending in a dollar sign ($) to appear, then quit Terminal.
    Step 2 (optional)
    Take this step only if you have trouble with Step 1, if you prefer not to take it, or if it doesn't solve the problem.
    Start up in Recovery mode. When the OS X Utilities screen appears, select
              Utilities ▹ Terminal
    from the menu bar. A Terminal window will open. In that window, type this:
    resetp
    Press the tab key. The partial command you typed will automatically be completed to this:
    resetpassword
    Press return. A Reset Password window will open. You’re not going to reset a password.
    Select your startup volume ("Macintosh HD," unless you gave it a different name) if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select
               ▹ Restart
    from the menu bar.

  • 2.5 inch black bands on either side of monitor

    I just installed Mavericks 10.9.2 on my Mac Mini and strange things have been happening, among them are two black bands on either side of the display.   How do I get rid of the bands and get my display back to the full width of my screen?

    In System Preferences > Displays there is a "Resolution" area. If the resolution is set to "Best for display", you should first make sure the monitor is configured correctly. If the monitor has an "Auto-Setup" function or button (most do), do that.
    If that doesn't fix it, you can select "Scaled" and try the various choices as well as the "Underscan" control, which isusually left at "off". 

  • Since last weekend (3-15-15) I have been unable to send/receive text messages with a friend who has Sprint service. The messages send with no errors on either side, but neither side is receiving the messages. Is anyone else having any similar issues?

    Since last weekend (3-15-15) I have been unable to send/receive text messages with a friend who has Sprint service. The messages send with no errors on either side, but neither side is receiving the messages. It seems to be only this one person affected by this issue, everyone else that I've tried sending messages to has responded with no trouble. Is anyone else having any similar issues?

    Retrohacker, Your text messages are too important to be missed! Let's figure this out, together. Are you able to successfully make and receive calls from your friend? Which phone do you have with us? Any new messaging applications or changes that you can recall on the phone since this issue began? Please share details so we can get to the bottom of this for you.  TanishaS1_VZW Follow us on Twitter @VZWSupport  If my response answered your question please click the "Correct Answer" button under my response. This ensures others can benefit from our conversation. Thanks in advance for your help with this!!

  • When I press slightly on either side of my macbook pro august 2011 trackpad or if I click the tracpad, I hear a light tick noise, sounds kinda like metal.  Anyone else have this problem? What is it?

    When I press slightly on either side of my macbook pro august 2011 trackpad or if I click the trackpad, I hear a light tick noise, sounds kinda like metal.  Anyone else have this problem? What is it?

    It's a spring-loaded grounding contact between the top case/chassis and the bottom pan of the machine. When you press, it scratches against the inside of the bottom pan and makes the sound. It's completely harmless and doesn't indicate that anything is wrong, but it can be slightly annoying. A visit to a Genius Bar may result in quieting it partially or completely.

  • Searching 2 years either side of a date field?

    Hi
    In my query I would like the search to be able to search 2 years either side of a specified search date in my interactive report
    select
    ROWID,
    ID,
    COLUMN1,
    COLUMN2,
    TO_CHAR(INDDOB, 'YYYY') AS NEWYEAR
    from TABLENAME
    ORDER BY INDDOB asc
    The interactive report is also using custom Javascript to offer an autocomplete search as per this thread For VC - Using multiple Autocomplete on a page?
    So I am unsure how this would work by allowing the date results to include 2 years either side of the chosen date?

    Mike many thanks for this
    INDDOB is a date field in the DB and the item name is :YEARD
    Using the following WHERE clause and a default vale of 1930 in the :YEARD item name is returning the correct result i.e. 1930 plus records from 1928,1929,1931 and 1932
    select
    ROWID,
    ID,
    INDSUB,
    INDDOD,
    INDREG,
    INDENT,
    INDDOD,
    INITCAP(INDSNAME) indsname,
    INITCAP(INDFNAME) INDFNAME,
    TO_CHAR(INDDOD, 'YYYY') AS NEWYEAR,
    DELDOC from   RAMBO.TABLENAME
    WHERE to_char(INDDOD,'YYYY') between :YEARD -2 and :YEARD +2
    ORDER BY INDDOD asc
    The problem is however when I try and change the search value in :YEARD from the default 1930 to for example 1950 (which is also in the db)
    When doing this it brings back no results? Could it be something to do with the associated code below which provides an autocomplete feature and search of the IA report as you type in the field name.
    In the :YEARD item under label and HTML table Cell attributes has the following
    onkeydown="if($f_Enter(event)){srch3($v('YEARD')); return false;}"
    and under the list of values in the definition for :YEARD is
    select distinct TO_CHAR(INDDOD, 'YYYY') from RAMBO.TABLENAME order by 1
    Also under page and Javascript is the following
    function srch2(pItem, pColumn) {  
       $.post('wwv_flow.show',
              {"p_request"          : 'APXWGT',
              "p_widget_action"     : 'FILTER',
              "p_widget_action_mod" : 'ADD',
              "p_widget_mod"        : 'ACTION',
              "p_widget_name"       : 'worksheet',
              "p_flow_id"           : $v('pFlowId'),
              "p_flow_step_id"      : $v('pFlowStepId'),
              "p_instance"          : $v('pInstance'),
              "x01"                 : $v('apexir_WORKSHEET_ID'),
              "x02"                 : $v('apexir_REPORT_ID'),
              "x03"                 : pColumn,
              "f01"                 : ['COLUMN', pColumn, '=', $v(pItem), null, 'minutes']
             function(data){
                //when the filter has been successfully applied the report has to be refreshed
                if(data=="true"){
                   gReport.pull();
       //clear the item
       $s(pItem,'');
    $(document).ready(function(){
       //hide IR toolbar
       $('#apexir_TOOLBAR').hide();
       $('#P4_AC').bind("result", function(){   
          //on selecting a value then fire the search function
          srch2(this, 'INDSNAME');
       // ac item P4_AC2
       $('#P4_AC2').bind("result", function(){   
          srch2(this, 'INDFNAME');
       // ac item YEARD
       $('#YEARD').bind("result", function(){
          srch2(this, 'NEWYEAR');
    // ac item REG
       $('#REG').bind("result", function(){
          srch2(this, 'INDREG');
    // ac item ENTNO
       $('#ENTNO').bind("result", function(){
          srch2(this, 'INDENT');

  • Changing background colour either side of 4:3 image on a 16:9 screen

    Hi there,
    I am using iDVD 6, and have a showreel made up of various formats of video. I have decided to make all my clips 4:3, letterboxing when the original image was widescreen, full frame for an original 4:3.
    I know it will be watched on a widescreen, so I want to make the the DVD in widescreen, to take advantage of the extra acreage for menus and so on. But when it comes to playing the showreel, even though the 4:3 reel is correctly at the centre of the screen, the vertical bars on either side are grey. This is very distracting. It would help enormously if I can make these black, to match the top and bottom bars of the letterbox images.
    I hope this is clear.
    I am using the reflection white theme, and very lovely it is too.
    Thanks - Nigel
    MacBook Pro 2.16 GHz Intel Core Duo   Mac OS X (10.4.8)   2GB RAM

    I'm replying to my own question, as I think I've solved it, or found my problem.
    In iDVD, playing back your project in preview mode gives you the grey side bars if you have a 4:3 image. But burning it to a desktop image, and playing the DVD treated a 4:3 image properly, clicking over to 4:3, and leaving either side black. I'm guessing that when I burn my DVD there will be no problem.
    Hope that helps anyone who gets in the same position.
    Nigel

  • HT4623 I cannot install my ipod to my computer. Says something about the device driver. I did not get it new either and so have no info about it. And I have never used one before and have no friends who have either. Can someone help me?

    I cannot install my ipod to my computer. Says something about the device driver. I did not get it new either and so have no info about it. And I have never used one before and have no friends who have either. Can someone help me?

    See
    iOS: Device not recognized in iTunes for Windows
    - I would start with
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    or              
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    However, after your remove the Apple software components also remove the iCloud Control Panel via Windows Programs and Features app in the Window Control Panel. Then reinstall all the Apple software components
    - New cable and different USB port
    - Run this and see if the results help with determine the cause
    iTunes for Windows: Device Sync Tests
    Also see:
    iPod not recognised by windows iTunes
    Troubleshooting issues with iTunes for Windows updates
    - Try on another computer to help determine if computer or iPod problem

  • My Mac has developed 2, 1 inch wide white lines vertically down either side of the screen. Is this the end?     lines

    My iMac has developed two 1 inch wide white vertical lines down either side. Is this the end? Or is there a fix?

    LornaDer,
    Run Apple Hardware Test in Extended Mode, you probably will need to run the test 2-4 times as errors do not always appear on the first pass. If you get errors then that indicates you have a hardware issue and need to take the machine into an Apple Store or AASP to be professionally diagnosed. At that point you can then determine your options.

  • Hello, I have a problem with my mac book pro after running the battery dead on a game.  The display has shrunk leaving two black margins on either side. What to do ?

    Hello, I have a problem with my mac book pro after running the battery dead on a game.  The display has shrunk leaving two black margins on either side. What to do ?

    Go to System Preferences>Displays and set the resolution to "Best for this computer" (or something to that effect).
    Clinton

  • Trying to install iCloud on Win7 get error message either no default mail client or current mail client cannot fulfill messaging request.   How fix?

    Trying to install iCloud on Win7 get error message either no default mail client or current mail client cannot fulfill messaging request.   How fix?

    Outlook 2013.  Under Start Up Options, I have checked "Make Outlook the default program for E-mail, Contacts, and Calendar".

  • HT1386 When I connect my 5s to itunes on my Pc  the sync gets stuck on either "downloading safari safe browsing data" or "waiting for changes to be applied".  Any ideas?

    When I connect my 5s to itunes for a sync, the sync gets struck on either Step 4, waiting for changes to be applied, or "downloading safe safari data."  This does not happen with my ipad.  Any suggestions would be appreciated.  Thx, Jimmy

    Same thing has been happening to me and I havent been able to find a fix. Itunes has basically rendered my phone uselsee. It wont see it, let alone sync it.

Maybe you are looking for