Jump to content

Drawing from Multiple Tables Problem


imperium2335

Recommended Posts

Hi,

 

I have a little script that shows a user or group of users' work based on branches and users.

 

I.e, I would like all the users of a given branch to be able to see all the other users' things who are in the same branch only.

 

But all I'm getting is far too many results (takes a long time to load!) not in any consistent format.

 

I have tried using GROUP BY etc but with no luck, I just get different crazy results.

 

$result = mysql_query("SELECT enquiries.*, users.*
					  FROM enquiries, users
					  WHERE enqState = 'New'
					  AND users.branch = '$userBranch'
					  AND enquiries.assignedToT = users.userName
					  OR enqState = 'New'
					  AND '$userLevel' > 4
					  ") ;

Link to comment
https://forums.phpfreaks.com/topic/234218-drawing-from-multiple-tables-problem/
Share on other sites

Thanks, I know I'm just being lazy  :shy:, will optimise it once I have it working.

 

users has this structure:

 

id userName userPass     branch

 

Enquiries has:

 

id detail_sheetRef assignedToT enqState

 

I'm not to well versed on JOIN, how would that help in this case?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.