Selecting multi columns into one ?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Selecting multi columns into one ?

    I have 3 tables with an ip column that i would like to get into 1 coloumn
    with an query

    Table 1 columns
    ID, IP
    Table 2 & 3 columns
    FROMID, IP

    I would like all ip columns in one column where id or fromid = 1

    is that possible ? or could i use a view to make it easier ?

    Thanks
    /Gustaf


    Gurra Guest

  2. Similar Questions and Discussions

    1. Why multi Radio buttons are Selecting
      Hi, In one of my project I am using 3 Radio buttons for selecting 3 different types of documents. Out of 3 radio buttons I have to select only one...
    2. Implications for a multi lingual, multi curreny e commerce site ??
      Hi I'm about to start wotk on a large e commerce site which is to be multi lingual and support multi currencies. The site needs full content...
    3. DataGrid: Selecting multiple rows/columns
      Hi, I would like to enhance the DataGrid by adding scripting functionality that allows the selection of multiple rows or columns via...
    4. Form validation for multi-rows and multi-columns
      Hello All, I have a classical ASP form with multi-rows and multi-columns that allows users to enter multiple records at once. How do you check...
    5. Selecting all columns, but in a different order in SELECT statement
      Thanks, i thought that was the case... just wanted to confirm it before i started working on it. Alex "Vishal Parkar" <vgparkar@hotmail.com>...
  3. #2

    Default Re: Selecting multi columns into one ?

    SELECT [col1]+[col2]+[col3] FROM ..."

    rs.fields.item(0).value would be how to retreive it.

    Or, for the slightly more coder-friendly way:

    SELECT [col1]+[col2]+[col3] As [TheCols] FROM ..."

    rs.fields.Item("TheCols").Value


    If the columns are different datatypes, there may be more to it than those
    examples though. We'd have to know what kind of database you're using to
    help with handling conversions though, I'd imagine.

    Ray at work


    "Gurra" <gurgel@telia.com> wrote in message
    news:%23RGyslI$DHA.2412@TK2MSFTNGP12.phx.gbl...
    > I have 3 tables with an ip column that i would like to get into 1 coloumn
    > with an query
    >
    > Table 1 columns
    > ID, IP
    > Table 2 & 3 columns
    > FROMID, IP
    >
    > I would like all ip columns in one column where id or fromid = 1
    >
    > is that possible ? or could i use a view to make it easier ?
    >
    > Thanks
    > /Gustaf
    >
    >

    Ray at Guest

  4. #3

    Default Re: Selecting multi columns into one ?

    On Thu, 26 Feb 2004 17:56:00 +0100, "Gurra" <gurgel@telia.com> wrote:
    >I have 3 tables with an ip column that i would like to get into 1 coloumn
    >with an query
    >
    >Table 1 columns
    >ID, IP
    >Table 2 & 3 columns
    >FROMID, IP
    >
    >I would like all ip columns in one column where id or fromid = 1
    >
    >is that possible ? or could i use a view to make it easier ?
    A view might be easier, or you can do a SELECT AS. Something like:

    SELECT Table1.IP, Table2.IP, Table3.IP AS IPAddresses
    WHERE Table1.ID = 1 OR Table2.FROMID = 1 OR Table3.FROMID = 1

    If the data types are different between columns you'll have a problem
    with this, so then you'd have to retrieve the data set and concatenate
    it in your code.

    Of course, your display of the recordset would use the IPAddresses
    alias instead of a column name. :)

    Jeff
    Jeff Cochran Guest

  5. #4

    Default Re: Selecting multi columns into one ?

    > SELECT Table1.IP, Table2.IP, Table3.IP AS IPAddresses

    I think you meant

    SELECT Table1.IP + Table2.IP + Table3.IP AS IPAddresses

    or maybe

    SELECT Table1.IP + ',' + Table2.IP + ',' + Table3.IP AS IPAddresses


    ....A


    Aaron Bertrand [MVP] Guest

  6. #5

    Default Re: Selecting multi columns into one ?

    On Fri, 27 Feb 2004 00:56:20 -0500, "Aaron Bertrand [MVP]"
    <aaron@TRASHaspfaq.com> wrote:
    >> SELECT Table1.IP, Table2.IP, Table3.IP AS IPAddresses
    >
    >I think you meant
    >
    >SELECT Table1.IP + Table2.IP + Table3.IP AS IPAddresses
    Yup. Gotta remember to think about what I'm doing. :)

    Jeff
    Jeff Cochran Guest

  7. #6

    Default Re: Selecting multi columns into one ?

    Thanks ! :)

    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> skrev i
    meddelandet news:u3jZGPJ$DHA.3772@TK2MSFTNGP11.phx.gbl...
    > SELECT [col1]+[col2]+[col3] FROM ..."
    >
    > rs.fields.item(0).value would be how to retreive it.
    >
    > Or, for the slightly more coder-friendly way:
    >
    > SELECT [col1]+[col2]+[col3] As [TheCols] FROM ..."
    >
    > rs.fields.Item("TheCols").Value
    >
    >
    > If the columns are different datatypes, there may be more to it than those
    > examples though. We'd have to know what kind of database you're using to
    > help with handling conversions though, I'd imagine.
    >
    > Ray at work
    >
    >
    > "Gurra" <gurgel@telia.com> wrote in message
    > news:%23RGyslI$DHA.2412@TK2MSFTNGP12.phx.gbl...
    > > I have 3 tables with an ip column that i would like to get into 1
    coloumn
    > > with an query
    > >
    > > Table 1 columns
    > > ID, IP
    > > Table 2 & 3 columns
    > > FROMID, IP
    > >
    > > I would like all ip columns in one column where id or fromid = 1
    > >
    > > is that possible ? or could i use a view to make it easier ?
    > >
    > > Thanks
    > > /Gustaf
    > >
    > >
    >
    >

    Gurra Guest

  8. #7

    Default Re: Selecting multi columns into one ?

    Thanks ! :)


    "Jeff Cochran" <jcochran.nospam@naplesgov.com> skrev i meddelandet
    news:403f4b3e.1358049952@msnews.microsoft.com...
    > On Fri, 27 Feb 2004 00:56:20 -0500, "Aaron Bertrand [MVP]"
    > <aaron@TRASHaspfaq.com> wrote:
    >
    > >> SELECT Table1.IP, Table2.IP, Table3.IP AS IPAddresses
    > >
    > >I think you meant
    > >
    > >SELECT Table1.IP + Table2.IP + Table3.IP AS IPAddresses
    >
    > Yup. Gotta remember to think about what I'm doing. :)
    >
    > Jeff

    Gurra 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