Jump to content

Help with displaying content from two fields that equal the same


ace2721

Recommended Posts

Hi Guys

 

what I need to do is display data from two different tables that equal the same value in a specific field

 

Table one has

 

ID        Title        Course      content

 

table two has

 

ID        Title        Start date      End date

 

I need a query that says if title from table one matches title from table 2  then will display the start and end date from table two

 

sorry if this is really simple I am a newbie

 

thanks inadvance

Link to comment
Share on other sites

I dont know exactly how to do it, but I know that you're going to want to look at Joins. You will join the two tables using the ID and title, and then you can easily echo out the dates.. Again, I don't know how to do this off the top of my head. I could easily do a Google search, find out and then tell you, but it will be much more beneficial to you if you Google it yourself :).

 

Denno

Link to comment
Share on other sites

The mysql query should look like this:

$r = mysql_query("SELECT * FROM table_one LEFT JOIN table_two ON table1_field = table2_field");

 

LEFT JOIN takes every record from `table one`, and attaches the records from `table two` for which the specified condition is true.

 

Link to comment
Share on other sites

ace, try read through this page: http://www.tizag.com/mysqlTutorial/mysqljoins.php

 

Another member "harristweed" linked it to me in a thread I recently started and it solved my query. I think what you are trying to do is pretty much exactly what they cover in this tutorial, using Joins.

 

*edit

 

Actually, ignore that - I see this thread has already been marked as "Solved"!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.