We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,328 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

php programming

how to left join works in mysql

3
Contributors
4
Replies
18 Hours
Discussion Span
8 Months Ago
Last Updated
5
Views
vthakor115
Newbie Poster
1 post since Sep 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Should be in Mysql forum:

http://bit.ly/OFmu6N

Squidge
Posting Pro in Training
433 posts since Dec 2009
Reputation Points: 111
Solved Threads: 65
Skill Endorsements: 5
-family table
Position    Age
Dad         41
Mom         45
Daughter    17
Dog 

-food table
Meal    Position
Steak   Dad
Salad   Mom
Spinach Soup    
Tacos   Dad
ome2012
Junior Poster in Training
57 posts since Sep 2012
Reputation Points: 2
Solved Threads: 16
Skill Endorsements: 1
left join codes here.....

<?php
// Make a MySQL Connection
// Construct our join query
$query = "SELECT family.Position, food.Meal ".
 "FROM family LEFT JOIN food ".
    "ON family.Position = food.Position"; 

$result = mysql_query($query) or die(mysql_error());


// Print out the contents of each row into a table 
while($row = mysql_fetch_array($result)){
    echo $row['Position']. " - ". $row['Meal'];
    echo "<br />";
}
?>
ome2012
Junior Poster in Training
57 posts since Sep 2012
Reputation Points: 2
Solved Threads: 16
Skill Endorsements: 1
heres the output....

Dad - Steak
Dad - Tacos
Mom - Salad
Daughter -
Dog -
ome2012
Junior Poster in Training
57 posts since Sep 2012
Reputation Points: 2
Solved Threads: 16
Skill Endorsements: 1

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0676 seconds using 2.68MB