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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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