Sub-queries assistance, please/

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Sub-queries assistance, please/

    Hi Everyone,

    For simplyfying things, let's assume that I have two tables MAIN and USERS

    USERS contains the fileds ID, FIRSTNAME, LASTNAME
    MAIN contains AUTHOR, EDITEDBY, APPROVEDBY

    My question is, how do I retrieve the three instances of FIRSTNAME and
    LASTNAME?
    I assume I need to use sub-queries, but have never successfully used them
    before...

    HeloWorld Guest

  2. Similar Questions and Discussions

    1. Need Assistance PLEASE
      I accidently changed my adminstative rights to limited. How do I correct this or access the administrator icon... It claims my administrator has a...
    2. I could use some assistance...
      I am having some issues with CF7 - I am sure it's just me being a newbie to Cold Fusion... But here is the deal... I need to set up several WSDLs to...
    3. Need some assistance please
      I will try to word this as best I can. Some info on our site first: We have tried to make our sites structure reflect our organizational...
    4. Queries Of Queries Single Quote Problem
      When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----...
    5. YOUR ASSISTANCE IN THESE MATTER.
      GULF BANK PLC, GULF BANK HOUSE, Plot 107 Ahmadu Bello Way V/Island Lagos. Nigeria. EMAIL:gulfbank_plc@yahoo.co.uk I am Mr. SIMON OTEDOLA,...
  3. #2

    Default Re: Sub-queries assistance, please/

    Your question is very vague. Here is a specific question. Firstname and Lastname of what?


    Dan Bracuk Guest

  4. #3

    Default Re: Sub-queries assistance, please/

    Hi Dan,

    What I am trying to do is return the first name and last name of three
    separate people.

    How do I return multilple values of FIRSTNAME / LASTNAME?
    One that corresponds to MAIN.AUTHOR and MAIN.EDITEDBY and MAIN.APPROVEDBY?

    Eg. MAIN.AUTHOR = '1', MAIN.EDITEDBY = '2' etc.

    USERS table contains ID, FIRSTNAME, LASTNAME
    1, fred, nurk
    2, john, smith

    I need a result set that allows john smith and fred nurk to appear on the same
    row.

    I was originally thinking of using a subquery... but perhaps I need to use
    Tables aliases? i really don't know - thus my asking :)


    HeloWorld Guest

  5. #4

    Default Re: Sub-queries assistance, please/

    Something like this will work on most databases. Different DB's allow more
    efficient methods:
    (I won't cover the left join case in this thread.)

    <b>
    SELECT
    tAuth.FirstName AS AuthNameFirst
    , tAuth.LastName AS AuthNameLast
    , tEdit.FirstName AS EditNameFirst
    , tEdit.LastName AS EditNameLast
    , tApprv.FirstName AS ApprvNameFirst
    , tApprv.LastName AS ApprvNameLast
    , tMain.AUTHOR <!--- Add any main column like this. --->
    FROM
    MAIN tMain
    , USERS tAuth
    , USERS tEdit
    , USERS tApprv
    WHERE
    tMain.AUTHOR = tAuth.ID
    AND
    tMain.EDITEDBY = tEdit.ID
    AND
    tMain.APPROVEDBY = tApprv.ID
    </b>


    MikerRoo Guest

  6. #5

    Default Re: Sub-queries assistance, please/

    Given this:
    USERS table contains ID, FIRSTNAME, LASTNAME
    1, fred, nurk
    2, john, smith

    How do I know who is an author, editor, etc?

    Dan Bracuk Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139