Jump to content

Recommended Posts

Can anybody see why the following sql query gives an mysql_error?

 

$clients_q = mysql_query("SELECT * FROM organisations where organisation_Id = (SELECT organisation_id FROM hosting WHERE server_id = '1')") or die(mysql_error);
$clients = mysql_fetch_array($clients_q);
$total_users = mysql_num_rows($clients_q);

 

Many thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/144062-subquery-mysql_error/
Share on other sites

How about you try using a JOIN instead:

 

SELECT o.*
FROM organisations o
JOIN hosting h ON h.organisation_id = o.organisation_Id
WHERE h.server_id = '1'

 

Something tells me the error might be related to the fact that your subquery returned more than 1 resulting row.  ;)

Link to comment
https://forums.phpfreaks.com/topic/144062-subquery-mysql_error/#findComment-755967
Share on other sites

why dont you try this

 

$client_q=mysql_query("SELECT * FROM organisations o, hosting h where o.organisation_Id=h.server_id='1'") or die(mysql_error());

$client=mysql_fetch_array($client_q);
$total_users=mysql_num_rows($client_q);

 

Do let me know if this works.

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/144062-subquery-mysql_error/#findComment-757363
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.