project3 Posted March 13, 2008 Share Posted March 13, 2008 what I have is two tables in on table is the select box name. in the other db is the options for the select boxes. for some reason the cart is adding select box and some have no options. what I want to do is make a select statement that will only select from select box db table if it has options in the options table how do I go about that? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
papaface Posted March 13, 2008 Share Posted March 13, 2008 Try: $conn = mysql_connect('localhost','username','password') or die (mysql_error()); $db1 = mysql_select_db("2nddatabasename",$conn) or die (mysql_error()); $db2 = mysql_select_db("1stdatabasename",$conn) or die (mysql_error()); You would then reference them as mysql_query("SELECT `something` from `tablename` where `something`='1'",$db1) or die (mysql_error()); I've never had to do this, so I am presuming this is how it is done. Quote Link to comment Share on other sites More sharing options...
project3 Posted March 13, 2008 Author Share Posted March 13, 2008 that just selects the value from one table. it needs to select from to at the same time. like using join. Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 13, 2008 Share Posted March 13, 2008 i can't think of a situation where you would need the queries happening at the EXACT same time. Quote Link to comment Share on other sites More sharing options...
corbin Posted March 13, 2008 Share Posted March 13, 2008 I'm assuming this is the right syntax: $link = mysql_connect('host', 'user', 'pass'); $q = mysql_query("SELECT db1.table1.col1, db2.some_other_table.some_column FROM db1.table1, db2.some_other_table"); Obvioulsy that query would be useless, but hopefully you see the <db>.<table>.<column> syntax. (Joins and stuff work with the same references I think.) The only time I've actually selected from 2 databases was with MSSQL.... It was like this, so I would assume MYSQL has a similar syntax (and the capability x.x): SELECT db1..table1.column1, db2..table2.column2 FROM db1..table1, db2..table2 (In MSSQL it's <db>.<user>.<table>.<column>) Quote Link to comment Share on other sites More sharing options...
project3 Posted March 13, 2008 Author Share Posted March 13, 2008 I'm assuming this is the right syntax: $link = mysql_connect('host', 'user', 'pass'); $q = mysql_query("SELECT db1.table1.col1, db2.some_other_table.some_column FROM db1.table1, db2.some_other_table"); Obvioulsy that query would be useless, but hopefully you see the <db>.<table>.<column> syntax. (Joins and stuff work with the same references I think.) The only time I've actually selected from 2 databases was with MSSQL.... It was like this, so I would assume MYSQL has a similar syntax (and the capability x.x): SELECT db1..table1.column1, db2..table2.column2 FROM db1..table1, db2..table2 (In MSSQL it's <db>.<user>.<table>.<column>) yes thats what i was going for. I got it to work thanks. Quote Link to comment 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.