Code: Select all
SELECT *
FROM eachsnake JOIN specieslist
ON eachsnake.Scientific_Name = specieslist.Scientific_Name
Is this code right? or am i missing something?
Moderator: General Moderators
Code: Select all
SELECT *
FROM eachsnake JOIN specieslist
ON eachsnake.Scientific_Name = specieslist.Scientific_Name
Code: Select all
SELECT * FROM eachsnake as ea
INNER JOIN specieslist as sp
ON ea.Scientific_Name = sp.Scientific_NameCode: Select all
<?php
// Make a MySQL Connection
mysql_connect("localhost:8889","root","root") or die ('Error connecting');
mysql_select_db("snakebook");
// Construct our join query
$query = "SELECT eachsnake.Avid, specieslist.Scientific_Name, specieslist.Common_Name, specieslist.Image, specieslist.Map, eachsnake.Origin, eachsnake.Location ".
"FROM eachsnake JOIN specieslist ".
"ON eachsnake.Scientific_Name = specieslist.Scientific_Name";
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
$avid = $row['Avid'];
$common = $row['Common_Name'];
$scientific = $row['Scientific_Name'];
$image = $row['Image'];
//display data
echo "<center><table border='0' cellpadding='5' cellspacing='0'>
";
echo "<tr>
<td><strong>$avid</strong></td>
<td><strong><i>$scientific</i></strong></td>
<td><strong>$common</strong></td>
<td>$image</td>
</tr>";
}Code: Select all
SELECT * FROM `db1`.`eachsnake` LEFT JOIN `db2`.`specieslist` ON `eachsnake`.`Scientific_Name` = `specieslist`.`Scientific_Name`