If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Get 2 database tables assign to one output

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-09, 17:55
Big-Gaz Big-Gaz is offline
Registered User
 
Join Date: Aug 2009
Posts: 2
Red face Get 2 database tables assign to one output

Hi,

I have 2 database tables:
XXXX_user
XXXX_userpoints

From XXXX_user I need:
id, username, gender, gender, floor(period_diff(extract(year_month from NOW()),extract(year_month from birth_date))/12) as age, allow_viewonline, city, country, state_province

From XXXX_userpoints I need
id, points

I am using PHP for coding.

Now I need to get data from both of them and assign them the same output
For example

$TopList = SELECT GET BOTH database tables
Then:
PHP Code:
foreach ($TopList as $row) { 
It is possible to get both at the same time under $TopList ?
If not can I get them as 2 separate ones then assign them both as $row if so how?

Thanks,
Big-Gaz
Reply With Quote
  #2 (permalink)  
Old 08-13-09, 18:08
Big-Gaz Big-Gaz is offline
Registered User
 
Join Date: Aug 2009
Posts: 2
Would this do it
ut. = user table
upt. = user points table

$TopList = $osDB->getAll ('SELECT ut.id as id, ut.username as username, ut.gender as gender, ut.allow_viewonline as allow_viewonline, ut.city as city, ut.country as country, ut.state_province as state_province, ut.floor(period_diff(extract(year_month from NOW()),extract(year_month from birth_date))/12) as age, upt.points as points FROM ! as ut ! as upt WHERE ut.status = ? ORDER BY points DESC LIMIT 10', array(USER_TABLE, USER_POINTS_TABLE, Active));

Thanks,
Big-Gaz
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On