note 85054 added to function.mysql-select-db

From: Date: Tue, 12 Aug 2008 23:57:57 +0000
Subject: note 85054 added to function.mysql-select-db
Groups: php.notes 
Request: Send a blank email to php-notes+get-143427@lists.php.net to get a copy of this message
Cross-database join queries, expanding on Dan Ross's post... Really, this is a mysql specific feature, but worth noting here. So long as the mysql user has been given the right permissions to all databases and tables where data is pulled from or pushed to, this will work. Though the mysql_select_db function selects one database, the mysql statement may reference another (the syntax for referencing a field in another db table being 'database.table.field'). <?php $sql_statement = "SELECT PostID, AuthorID, Users.tblUsers.Username FROM tblPosts LEFT JOIN Users.tblUsers ON AuthorID = Users.tblUsers.UserID GROUP BY PostID,AuthorID,Username "; $dblink = mysql_connect("somehost", "someuser", "password"); mysql_select_db("BlogPosts",$dblink); $qry = mysql_query($sql_statement,$dblink); ?> ---- Server IP: 209.41.74.194 Probable Submitter: 24.107.184.98 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-select-db.php Edit -- https://master.php.net/note/edit/85054 Del: integrated -- https://master.php.net/note/delete/85054/integrated Del: useless -- https://master.php.net/note/delete/85054/useless Del: bad code -- https://master.php.net/note/delete/85054/bad+code Del: spam -- https://master.php.net/note/delete/85054/spam Del: non-english -- https://master.php.net/note/delete/85054/non-english Del: in docs -- https://master.php.net/note/delete/85054/in+docs Del: other reasons-- https://master.php.net/note/delete/85054 Reject -- https://master.php.net/note/reject/85054 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143427) next »