Jump to content

Combining Queries


hebie136

Recommended Posts

I'm new to php and mysql and I'm after a bit of help with php and mysql in that I need to combine 2 queries into 1 or at least I think that is where my problem is.......

 

I have 2 tables, profiles and sys_acl_levels_members from which I need to pull bits of information from both tables to make one set of results.

 

Both tables use a field called ID which links them together..... Hope this all makes sense so far......

 

I am trying to populate bits of information which work fine when only 1 query is run.  If I try to run both, then the last query over rides the first (if that makes any sense)

 

The first query grabs things like Nickname, Sex, Role and Town, etc...... and works fine on its own.

 

// Fetch User Data - Nickname, Role, Sex, Town etc......
$sql = "SELECT * FROM Profiles WHERE ID=$strSessionGUID";
$gatherUsers = @mysql_query ($sql) or die('MySQL error: ' . mysql_error() . '<br>Query: ' . $sql);
while($users=mysql_fetch_array($gatherUsers))

 

 

With this second query I need to pull some membership information.

 

                    
//Fetch Membership Data 
$sqlmembs = "SELECT IDLevel FROM sys_acl_levels_members WHERE IDMember=$strSessionGUID";
$gathermembers = @mysql_query ($sqlmembs) or die('MySQL error: ' . mysql_error() . '<br>Query: ' . $sqlmembs);
while($membs=mysql_fetch_array($gathermembers))

 

 

Both work find on their own but not together, so I am thinking if I can combine them it may work.....

 

Anyone help shine some light on things.....

 

 

 

Many thanks

 

Mark

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.