I have several SELECT queries on a few of my webpages, and I have been told that the more query connections that are open the slower the server will run.
So firstly, is it possible to merge/combine 2 SELECT queries into a single query?
Current I use 2 or more like below:
$a=mysql_query=("SELECT fields FROM table WHERE userid = '{$_SESSION['userid']}'");
$aa=mysql_fetch_assoc($a);
$b=mysql_query=("SELECT fields FROM table WHERE userid = '{$_SESSION['userid']}'");
$bb=mysql_fetch_assoc($b);
//then print the values within the page where needed
print $aa['field'];
print $bb['field'];
can they be combined? maybe something such as below (except im not sure about the WHERE statement)
$a=mysql_query("SELECT a.fieild, b.field FROM a.table, b.table WHERE a.userid = '{$_SESSION['userid']}', b.userid = '{$_SESSION['userid']}'");
$aa=mysql_fetch_assoc($a);
//print values when needed
print $aa['a.field']
//although im sure i dont need the a. above, and with both tables having different field names there should be no name conflict
And secondly, if the above is possible, would this reduce the number of connections to the SQL database and therefore save some of the servers resources?