Page 1 of 1

Comments

Posted: Thu Apr 16, 2009 3:21 am
by nachoman316
Hello I am trying to link user comments to particular articles in a website I am developing.

I have two mysql database tables Programme and Comments.

Programme has a primary key of progid which is also a foreign key in Comments.

But I am having trouble with the query retrieving the programme article and the comments attached to that article in the same page.

Im a total noob Im more of a front end developer but would love to get more experience with php.

Any help would be great.

Thanks Nacho.

Re: Comments

Posted: Thu Apr 16, 2009 3:47 am
by Apollo

Code: Select all

SELECT * FROM Programme WHERE progid=37; // this will select a specific programme
 
SELECT * FROM Comments WHERE progid=37; // this selects the comments that belong to it

Re: Comments

Posted: Thu Apr 16, 2009 3:53 am
by papa
Or one query:

Code: Select all

 
SELECT * FROM Programme AS a
JOIN Comments AS b ON a.progid=b.progid
WHERE a.progid = 37
 

Re: Comments

Posted: Thu Apr 16, 2009 4:03 am
by nachoman316
Thanks for the help guys I'll give those a bash.

Cheers Nacho