Results 1 to 7 of 7

Thread: Need help with a query ...

  1. #1
    Join Date
    Nov 2008
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Need help with a query ...

    Hello:

    I am trying to get a mysql query together an not quite sure how to apply it, whether it is with distinct, join and all. What I am looking is to get the ID, qty ( number of users ), max and min number. Can anyone help me with this please.


    Name ID Name
    123ABC Engine
    649DFA Transmission
    854UDF Window


    User ID User Name User Amount
    123ABC Paul 300
    123ABC John 190
    649DFA Ian 500
    123ABC Mary 210
    123ABC Mark 225
    649DFA Steve 360




    Required Result:

    ID Qty Max Mix
    123ABC 4 300 190
    649DFA 2 500 360

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    So you have 2 tables one with 3 columns and one with 4 linked with ID?
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Nov 2008
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Yes Blue.
    I dont know why they bunched thme together. Thew link would be in the ID.

    Name ID, Name


    User ID, User Name, User Amount

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,717
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    most browsers will condense whitespace. I don't know why. I find it rather annoying myself. To get around it you will need to use non-breaking spaces. In this forum I believe the only way to do that is to use   to create the HTML version of it.

    Other than that I recommend wrapping your code with code tags for readability.

    I see that you have two tables. One table has three columns, but only two of which have data. In your second table you have three columns and data for all three columns, but I usually read spaces between table names as separators.

    test           test
    Last edited by james438; 05-01-2010 at 03:29 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    For this sort of thing a <table> might be the best way to do it. Tables aren't always a good idea, but for tabular data they're great.

    The reason that HTML ignores whitespace is because that is normal for all programming languages. Formatting is ignored and only the commands and text content are included. It is annoying for HTML, though it also helps because you can use tabs to organize the code, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    I think the OP is looking for a sql statment not html help, also the entity for a space can also be &nbsp;.

    Code:
    GO
    SELECT a.name, a.ID, a.name, b.User, b.ID, b.name, b.amount
    FROM table1 AS a
        INNER JOIN table2 AS b
        ON a.id = b.id
    Not familiar with max and min functions

    http://www.techonthenet.com/sql/min.php
    http://www.techonthenet.com/sql/max.php
    Corrections to my coding/thoughts welcome.

  7. #7
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,717
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    also the entity for a space can also be &nbsp;.
    not quite as seen in the following example:

    test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test

    I do believe you understand the question best. I was/am having trouble reading the question in the first post.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

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