mysql queries



msql

db Connect:

<?php
$dbhost = 'localhost';
$dbusername = 'root';
$dbpassword = 'dev2tricks';
$conn = mysql_connect($dbhost,$dbusername,$dbpassword);
if($conn!=""){
die('could not connect: '.mysql_error()); }
else{
echo 'db Connect Successfully';
}
 ?>

The SQL Query SELECT command is used to fetch data from mysql database table.  You can use this command at mysql syntax sample code prompt as well as in any script like php.

SELECT Query Syntax:


SELECT * FROM `table_name`;
or
 SELECT field1, field2, table-name1, table-name2 ... [WHERE Clause]  [LIMIT N]


Example code:

$sql = 'SELECT * FROM `table_name`';
mysql_select_db('db_name');
$con = mysql_query($sql, $conn);
while($datas = mysql_fetch_array($con))
{
echo "$datas['field-name']";
}


Table Field Name Rename:

It is important to remember that the table hasn't actually been renamed, but instead the new_table_name.

SELECT `fieldname` As 'new name' from `tablename`;


More MYSQLJOINQUERY





mysql queries Developerinvention 5 of 5
db Connect: <?php $dbhost = 'localhost'; $dbusername = 'root'; $dbpassword = 'dev2tricks'; $conn = m...

Share this

Related Posts

Previous
Next Post »

Xolo Offer