#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    5
    Rep Power
    0
    Hallo,
    I'm from german, so I can't write english not verry well!

    My problem is the follows:
    There are two tables
    both with an Column there are inside the same
    the first one is a main table with entries like PersonalDB FirstName, LastName, Birthday aso...
    the second one is a table "under" the main table with entries like PersonalDB EntryDate, Message, User, timestamp aso...

    that means the second table has any entries wich will show if choose one entry from the first table. Understand me?

    first table secon table
    1. 1.1
    2. 1.2
    3. 1.3
    2.1
    2.2
    3.1
    3.2
    ...

    Well, I'm looking for a posibility that you can see all entries of the first tables and the youngest data of the second table
    LIKE:

    first table second table
    1. 1.3
    2. 2.2
    3. 3.2

    Understand me? I hope so! And I need YOUR help!
    Please help, if you can an send me an email or post your answer behind my posting!

    Thanks a lot!
    By,
    Hannes
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    5
    Rep Power
    0
    I have used the follow select-statement:

    SELECT rma.rmanr, geraet, verlauf.bearbeiter, verlauf.massnahme, verlauf.timestamp, verlauf.status
    FROM rma, verlauf
    WHERE rma.rmanr=verlauf.rmanr
    ORDER BY verlauf.timestamp desc

    this is a sort but it is not grouped!
    If I grouped this I have got fals datas!
    I have to have a statement wich will first order an after this the result has to group!

    Thanks a lot!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    60
    Rep Power
    15
    You write English better than I write German...

    So, if I understand your question, you would like to do a JOIN of two tables based on a field that appears in both tables ("rmanr?").

    As I just learned today, JOINs of this type aren't possible with MySQL 3.22. In Mysql 3.23, it is possible to create a TEMP table in which you can create all of the fields from both tables. It's a messy JOIN but it works.

    If I am wrong, I would love to know how to do this more cleanly. Ideas?
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    Yes, joins are possible with 3.22.xx. I use joins constantly and normalization is quite useless without them.

    Hannes,

    You haven't said HOW you'd like the query grouped, and I don't see any functions in the query where a GROUP BY clause is going to be used.

    I'm also curious as to WHY you need a join here since rmanr is the only column you are getting from table rma (unless geraet is from that table, it's lacking a table designator).
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    5
    Rep Power
    0
    My selct-Statement is the follows:
    SELECT verlauf.RMANr,rma.geraet,verlauf.Bearbeiter,verlauf.Status,verlauf.TimeStamp
    from rma,verlauf
    where rma.rmanr=verlauf.rmanr and verlauf.status<>'geschlossen'
    GROUP BY verlauf.RMANr
    order by verlauf.rmanr, verlauf.timestamp";

    The result isn't the right result!
    Better use
    first ORDER BY and then GROUP BY, but this is a false sql-statement - understand me!

    The table "verlauf" will grow verry fast! So I think it is not a good idea using a TEMP TABLE!

    looking forward to your answers!
    Nice to received your messages!!!
    Thanks a lot!

    Hannes
  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    I still don't understand why you are using a GROUP BY clause. GROUP BY is used when you are using a function that would operate across several records (such as count(), avg(), min(), max(), etc) and you want to group the results by the value of another column. You are not using one so the GROUP BY should have no affect. The best I can understand from your explanation, this:

    order by verlauf.rmanr, verlauf.timestamp

    should be enough to do what you want.
  12. #7
  13. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    order by verlauf.rmanr, verlauf.timestamp


    Actually that is enough for him to sort it in a proper way.

    Hannes,,
    see the mysql manual. their you can see some examples for group by and order by.
    It has explained when you should use group by and order by clauses.




    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited June 23, 2000).]

Similar Threads

  1. Replies: 1
    Last Post: April 14th, 2003, 10:36 AM
  2. Select some first, select the rest after in other file
    By quiquedcode in forum PHP Development
    Replies: 4
    Last Post: March 2nd, 2003, 04:17 PM
  3. SQL Queries Query!!!!!!
    By Paul_Statham in forum MySQL Help
    Replies: 8
    Last Post: April 9th, 2002, 09:14 PM
  4. select distinct question
    By kjg in forum MySQL Help
    Replies: 2
    Last Post: February 9th, 2002, 12:12 PM
  5. Passing desc from select box into text box
    By acetone_lin in forum HTML Programming
    Replies: 2
    Last Post: August 31st, 2001, 06:16 PM

IMN logo majestic logo threadwatch logo seochat tools logo