User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » mySQL query question Page [1]  
BigMan157
no u
103352 Posts
user info
edit post

how can i limit the results of one query by the results of another one?

like, if i want to get the users from one table and use the result to get only users that aren't on that first table from ANOTHER table?

i know there has to be a simpler way than looping through each result and querying for each single user

2/21/2006 7:12:26 PM

qntmfred
retired
40562 Posts
user info
edit post

do a google search on JOINS

2/21/2006 7:13:43 PM

OmarBadu
zidik
25067 Posts
user info
edit post

how do you know what mysql is and not know this? this is very basic sql

2/21/2006 7:16:22 PM

BigMan157
no u
103352 Posts
user info
edit post

still cant get it working the way i want it to

2/21/2006 8:35:59 PM

Maugan
All American
18178 Posts
user info
edit post

select * from whatever_table t where t.userid = (select distinct userid from users);

assuming you have a properly setup relational database. This is a pretty simple way of going about it.

On a related note, whats the fucking deal with everyone asking all these SQL questions?

get a book!

[Edited on February 21, 2006 at 9:01 PM. Reason : I always forget the distinct]

2/21/2006 9:00:14 PM

BigMan157
no u
103352 Posts
user info
edit post

i figured it out using a left join like five seconds after saying i couldn't get it working

2/21/2006 9:05:46 PM

 Message Boards » Tech Talk » mySQL query question Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.