Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Can I use a column as the table name for a join query? [PHP/MYSQL]
Old 08-10-2010, 02:46 PM Can I use a column as the table name for a join query? [PHP/MYSQL]
Extreme Talker

Posts: 170
Location: Canada
Trades: 0
I haven't executed this script yet, but I wanted to know whether or not I could execute a JOIN query, using a column's result as the table name for that query. It sounds really recursive, but I believe it should be possible.

Example:

PHP Code:
$q_relate "SELECT * FROM attr_relationships ar
                JOIN ar.attr_table rr ON ar.attr_id = rr.id
                WHERE ar.parent_table='"
.$parent_table."' AND ar.parent_id='".$parent_id."'"
Please advise if my syntax is incorrect, or if my approach to this is impossible.

I can always run a second query with the results of a select query, but that doesn't seem as elegant to me.
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
collyer_1 is offline
Reply With Quote
View Public Profile Visit collyer_1's homepage!
 
 
Register now for full access!
Old 08-10-2010, 03:44 PM Re: Can I use a column as the table name for a join query? [PHP/MYSQL]
Extreme Talker

Posts: 149
Trades: 0
Query looks ok, but you use a normal JOIN and can be slow
__________________
Free
Please login or register to view this content. Registration is FREE

Visit our
Please login or register to view this content. Registration is FREE
and
Please login or register to view this content. Registration is FREE
mimamo is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Can I use a column as the table name for a join query? [PHP/MYSQL]
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20342 seconds with 12 queries