Edmund,

As Ma'moon says, your question has nothing to do with CakePHP which is
a framework built using PHP and to take that further your question has
little to do with PHP as it's MySQL you're currently struggling with.

You would be better reading some MySQL tutorials and getting to grips
with that before also emersing yourself into connecting via PHP and
echoing out your results.

When getting to grips with MySQL it's always good to be able to
connect with somehting like phpMyAdmin where you can run SQL direct
against the tables and see your results without wondering if something
has gone wrong in your PHP code, so make sure you have access to some
MySQL admin client that allows you to do that.

HTH, Paul

P.S. If you've got unique ResultSetID in one table and multiple
ResultSetID in the other table you have a hasMany <-> belongsTo
association.  Any join you make using a single query in MySQL [SELECT
* FROM resultsets INNER JOIN ON(resultsets.ResultSetID =
questiondata.ResultSetID)] will repeat the data from the unique table
alongside the related multiple rows from the other table which isn't
very useful or efficient.

The most likely real world use of this data would be that you select a
row from the table with unique values and it then displays all related
rows from the 2nd table with a query such as simple as [SELECT * FROM
questiondata WHERE ResultSetID = $idVariable]

On Aug 18, 10:59 am, Edmund Wilson <[email protected]>
wrote:
> Hi I am trying to make a simple PHP page that queries a MySQL
> database.
>
> There are two tables created by a program (I don't have any control
> over the creation of these tables) but they both created by the same
> data source.
>
> I was trying to form a FULL JOIN to display data from both tables in
> one web page - However I can't seem to get this to work. The only
> common column in both is ResultSetID which in one is totally unique -
> the other is repeated (although the identifier does relate to the same
> user and data entered by that user)
>
> The two tables are:
>
> resultsets: (which contains the following columns)
> ResultSetID, Candidate, QuizName, PercentageScore, PercentagePass,
> PassFail
>
> and
>
> questiondata (which contains the following colloums)
> ResultSetID, SectionReference, Responce
>
> The code I have strung together so far is as follows:.....
>
> <?php
>
> // Make The MySQL Server + Datebase Connection
> mysql_connect("localhost", "root", "") or die(mysql_error());
> mysql_select_db("questions") or die(mysql_error());
>
> // Construct our join query
> $query = "SELECT * FROM questions.resultsets
>           FULL JOIN questions.questiondata
>           ON ResultSetID";
>
> $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['resultsets.ResultSetID']. " - ".
> $row['questiondata.QuestionID']. " - ". $row['questiondata.Responce'];
>         echo "<br />";}
>
> ?>
>
> But the output I am getting from the webpage is:
> Column 'ResultSetID' in on clause is ambiguous
>
> Is this because the ResultSetID in the questiondata is not unique per
> row? And if so is there any way to merge the two tables together?
>
> Sorry to be a real novice but I only started to look at PHP and MySQL
> last night!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to