Jump to content

Combined query not working


imperium2335

Recommended Posts

Hi,

 

Is there a more efficient way of doing this?

 

$result = mysql_query("SELECT users.id
						   FROM users, active_users_dyn
						   WHERE users.id = active_users_dyn.userRef
						   AND users.username = '$user' LIMIT 1")or die(mysql_error()) ;
	$result2 = mysql_query("SELECT users.id
						   FROM users
						   WHERE users.isRegistered = 1
						   AND users.username = '$user' LIMIT 1")or die(mysql_error()) ;

	$errz = mysql_num_rows($result) + mysql_num_rows($result2) ;

 

I have tried combining them into one query using another set of ANDS with an OR but it brings back 0 rows even though I know there is one.

 

Also, since I'm only interested in the number of rows, do I have to SELECT something even though I don't need it?

Link to comment
https://forums.phpfreaks.com/topic/236484-combined-query-not-working/
Share on other sites

Thanks, but it didn't work :(

 

Same result as:

 

$result = mysql_query("SELECT users.id
						   FROM users, active_users_dyn
						   WHERE users.id = active_users_dyn.userRef
						   AND users.username = '$user'
						   OR users.isRegistered = 1
						   AND users.username = '$user' LIMIT 1")or die(mysql_error()) ;

 

Saying there are no rows.

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.