here a basic background to this question.

all databases are build from various module bases. one module is the
database itself prosessing eg. the sql's another module is the database
connectivity. e.g. mySQL has a ability to connect thru ADO, .NET and an
server via IP.

MySQL supports unlimited databases comtaining tables. so from the point of
the database u have always to selct the database and then to the table.

however, if u study the various Database extensions u will find functions
(eg. mysql_db_query() ) where u point the database in the function call
while others don't (eg. mysql_query() ) on those u have to do a db select
first because the function itself doesn't do it, while mysql_db_connect()

so if we know that now, we are coming to the question, why are database
extensions do have those two types of processing a sql statement?

the answer is: speed ! while those commands with a pointing out the database
do internally a select of the database they do it every time on each call.

if u have a application which does a lot of stuff at the same time other
then just select statement, this comes into consideration. it saves time to
do one select_db first and then 50 just raw sql's to that database.

now after dumping that much stuff on u, it depends on ur design if u need a
select_db first or not.

hope that helps

"Allen McCabe" <> wrote in message
> I have seen different scripts for working with SQL, and most follow the
> method with on difference.
> Variables are defined (host, password, etc.)
> mysql_connect command
> //then, the difference
> mysql_select_db command
> //back to common
> $sql = "SELECT ... "
> $result = mysql_query($ql)
> Is the database selection necessary, or is that implied with a SELECT or
> other SQL command?

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to