Jump to content

[SOLVED] need some help with php and mysql...


CSmith1128

Recommended Posts

Hello. I am using multiple databases on my site.

 

I was wondering if it were possible to select something from a database based on information from another database..

 

for example..

i want to select the user_id of a user where their age (found in database 1) is 28 and the gender of that person (found in database 2) is male.

 

is this possible?

 

i am trying to do it in 1 query, if thats possible..

if not, thats fine.. whatever works and is most efficient.

 

thanks!!

Link to comment
Share on other sites

SELECT a.userID

FROM database1.table1 a

INNER JOIN database2.table2 b ON a.userID = b.userID

WHERE a.age = 28

AND b.gender = 'male'

 

 

what is the 'a' and 'b' in there for?

what do they represent?

im not as familiar with JOINS as i should be and i am confused right there..

 

thanks!

Link to comment
Share on other sites

$mysql_database="this_db";

$mysql_username="user";

$mysql_password="password";

 

$dbcnx = mysql_connect("localhost",$mysql_username,$mysql_password) or die("Unable to Connect to the Server at This Time... Please Try Again Later.");

mysql_select_db($mysql_database, $dbcnx) or die ("Unable to Connect to the Server at This Time... Please Try Again Later.");

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.