MySQL Forums
Forum List  »  Newbie

MySQL 4.1 Combining multiple SELECTs
Posted by: Mathias Herrmann
Date: July 13, 2005 02:47AM

Hi everybody!

Since I´m quite new to this stuff, this might seem not that big of a problem to you as it is to me, but here we go:

I set up a employee-database system. Some of the users herein can change information of other users and of themselves and now I am trying to combine two select statements to produce one resultset.

table1 table2
|-id (int10) |-userid (int10)
|-name |-changesuser (int10)
|-firstname1
|-...

What I did:

SELECT id,name,firstname FROM table1 INNER JOIN table2 ON table1.id = table2.changesuser WHERE table2.userid = '100' ORDER BY table1.name,table1.firstname ASC;

This works just fine and as I expected it to and produces a resultset of all the users that the user with the id "100" is allowed to edit.

SELECT id,name,firstname FROM table1 WHERE id='100'; gets me the user himself.

Now I need to combine these two statements into one producing a resultset of the user with the given id and all the otherusers that he is allowed to edit.

Help definitely needed!

Thanks in advance!

Best, M.

Options: ReplyQuote


Subject
Written By
Posted
MySQL 4.1 Combining multiple SELECTs
July 13, 2005 02:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.