jaymc Posted September 24, 2009 Share Posted September 24, 2009 SELECT cvn.clientID FROM wecan.client_virtual_numbers cvn INER JOIN wecan_{I NEED THIS TO BE VALUE OF cvn.clientID}.table WHERE cvn.number = '145' WHERE I have {I NEED THIS TO BE VALUE OF cvn.clientID} that IS the name of the database e.g wecan_4 Can this be done? Something like this would be nice SELECT cvn.clientID FROM wecan.client_virtual_numbers cvn INER JOIN wecan_(SELECT clientID from wecan.client_virtual_numbers where number = '145').table WHERE cvn.number = '145' Quote Link to comment https://forums.phpfreaks.com/topic/175376-solved-syntax/ Share on other sites More sharing options...
gevans Posted September 24, 2009 Share Posted September 24, 2009 At the moment the code is kinda pointless... The syntax is a little wrong, but putting that to one side you're only SELECTing the `clientID`. What are the table structures, and what are you hoping to get from each table? What's the initial value you have to pull the correct row(s)? Quote Link to comment https://forums.phpfreaks.com/topic/175376-solved-syntax/#findComment-924208 Share on other sites More sharing options...
jaymc Posted September 24, 2009 Author Share Posted September 24, 2009 Im a bit limited, this is for use with SMS, i receive a post which contains only a number in a table I have that number along with a clientID the clientID is actually part of the customers database name e.g. wecan_{clientID} = a customers database:- wecan_1 = customers database 1 wecan_2 = customers database 2 wecan_3 = customers database 3 wecan_4 = customers database 4 The problem is, the POST with the number does not contain the clientID therefor I cant join the customers DB without first knowing what the customers clientID is. I could do a query to first fetch this then run another query, but I am trying to put this all in one query.. Quote Link to comment https://forums.phpfreaks.com/topic/175376-solved-syntax/#findComment-924217 Share on other sites More sharing options...
gevans Posted September 24, 2009 Share Posted September 24, 2009 It seems to be you're going to have to use two queries. You can't build a table name during the query. Quote Link to comment https://forums.phpfreaks.com/topic/175376-solved-syntax/#findComment-924224 Share on other sites More sharing options...
jaymc Posted September 25, 2009 Author Share Posted September 25, 2009 Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/175376-solved-syntax/#findComment-924865 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.