Select query from custom tables in Wordpress

I am attempting to select details from a table using multiple strings from another table in Wordpress.
The first table has project details which are assigned to clients and the second table has the client details. There may be more than one client assigned to a particular project. So I need to find a loop that will work in this instance, as currently it only displays one client’s details
The code is as follows:

$clients=$wpdb->get_results($wpdb->prepare( " SELECT * FROM vo_wp_assigned_projects where project=‘$project_id’"));

foreach($clients as $list){
	$project=$list ->project;
	$client=$list ->client;
	$id=$list->client_id;
	$name=$list->name;
	$users=$wpdb->get_results($wpdb->prepare(" SELECT * FROM vo_wp_clients where user_id =‘$id’"));
	
	foreach($users as $user){
		$users_id=$user ->user_id;//echo $users_id;
		$client=$user->user_name;
		$title=$user->user_title;
		$phone=$user ->user_info;//echo $phone;
		$email=$user ->user_email;
	}
}

What am I missing here

Youre overwriting the output values inside the loop without using them?

If i do

for($x = 0; $x < 5; $x++) {
$y = $x
}

then at the end of my loop, $y is 4. not 0 or 1 or 2 or 3

Perhaps I should have said that the output of $id would be something like 1,2,3.
If this were passed through a multiple selection from a form, one can use a foreach statement and the results would then run through the second query for each of the elements in $id (hope that makes sense)
What I am trying to work out is how to do this after running the select query from the assigned_projects table

So inside the users loop you’ve got an output line you’re not showing us?

Hi folks
The issue is fixed. Turns out that there wasn’t actually anything wrong with this part of the query - it was a foreach further down.
Classic case of not seeing the wood for the trees