Jump to content

SQL help

- - - - -

  • Please log in to reply
5 replies to this topic

#1
bambi

bambi

    Newbie

  • Members
  • Pip
  • 6 posts
Hi, having a problem with my mysql select.
I have 2 tables:
user_info: user_id, f_name, l_name.
events: user_id, affected_user_id, action. (user_id "pointing to" user_info.user_id)

I want to gather user_id, f_name, l_name, action TOGETEHR WITH user_id (affected_id) f_name, l_name in one selection.

meaning.. in one row the output should be like:

(id) 22, (fn) Steve, (ln) Smith, (act) Paints, (affected_id) 83, (fn) John, (ln) Johnson.

Anyone?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
you need to use a join.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
bambi

bambi

    Newbie

  • Members
  • Pip
  • 6 posts
Yes, I've tried many different approaches but I cannot figure it out.
The problem is that I don't understand how to get two different persons user_id, f_name and l_name from the same table into the same row on out put.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You'll need to have more than one join, one for each person.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
bambi

bambi

    Newbie

  • Members
  • Pip
  • 6 posts
Could someone please write those line of sql needed for this operation? I do not manage it on my own.

#6
bambi

bambi

    Newbie

  • Members
  • Pip
  • 6 posts
Solved it with nested queries.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users