Jump to content

iamgregg

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

iamgregg's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. SELECT emp.Emp_name AS Employee, mgr.Emp_name AS Manager FROM emp LEFT JOIN emp AS mgr ON mgr.Emp_id=emp.Mgr_id This will return the name of every employee with the name of their manager (except the manager name for Rick will obviously be a NULL value - this is why LEFT JOIN is used instead of INNER JOIN; if INNER JOIN is used, Rick would be omitted from the result set). E.g. |--------------------| | Employee | Manager | |--------------------| | Alex | Bob | | Bob | Rick | | Rick | NULL | | Tom | Bob | | Laura | Bob | |--------------------|
  2. Could it be something as simple as stating auto_increment twice? [quote]) ENGINE=MyISAM [b]AUTO_INCREMENT=1758[/b] DEFAULT CHARSET=latin1 [b]AUTO_INCREMENT=1758[/b] ;[/quote]
  3. I just found the solution from someone else but thankyou for replying anyway. [i][b]fenway: if that's the case, post it here for all to see![/b][/i]
  4. I'm fine with normal join queries, but I'm having trouble with this one. I don't think I explained it well in the topic title so I'll go into more detail. Two tables: users pairs Table users has details about said users. The pairs table contains the 2 fields: user_1 and user_2, which are the respective users IDs. In one qury I want to grab the name of each user. I can do it fine for one of them but not sure how to both, e.g. how would I expand this? SELECT pairs.user_1, users.name FROM pairs, users WHERE pairs.user_1 = users.id I can't figure out how to do it for both? The furthest I get is SELECT pairs.user_1, pairs.user_2, users.name FROM pairs, users WHERE pairs.user_1 = users.id AND pairs.user_2 = users.id I know it's wrong. Anyone know? Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.