Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difficult MYSQL query !??

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
HI

i have this db structure :
Name IDPROJECT
user1 MON010018
user2 MON010018
user3 MTA010012
user4 JON020020

and i would like to make a SELECT query that select all fields where IDPROJECT corresponding to the user i've selected AND the other users correponding the same IDPROJECT.

for example, if i want to select user1, the query return :
user1 MON010018
user2 MON010018

REALLY LOT OF THANKS !!
 
hi there,

you should use a simple nested query like this:

SELECT * FROM test WHERE oms IN (SELECT oms FROM test WHERE user = 'user1');


grtz
CPUburn
 
it will not work in MySQL.


Try

SELECT * from table group by user,allotherfields Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
hello
u can also do something like this

the query will be
select idproject from tablename where name='user1';
from that u will get a projectid(store it in say $id) and then u can fetch records like


select * from tablename where idproject='$id'


hope that will help u

spookie

 
SELECT name, idproject FROM table_name
WHERE idproject=(SELECT idproject FROM table_name
WHERE name='user1');


Note : it is standard SQL
 
he can't use nested queries in MySQL.
you have to do it in 2 steps ...

sorry :(

$project=select project from projects where user = '$user'


select user,project from projects where project='$project'

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top