Query problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
chiching72
Forum Newbie
Posts: 3
Joined: Tue Jun 26, 2007 8:40 pm

Query problem

Post by chiching72 »

Hello all,

I have a query and I'm not sure why it's giving me 2 rows of the same results. Can someone tell me what I am writing wrong?

Code: Select all

$query = "SELECT Lesson.lesson_name, Lesson.title, Lesson.content, Images.imageinfo, Images.description
				FROM Lesson, Images WHERE (Lesson.lesson_id = '$LESSON' && Images.lesson_id = '$LESSON')";
Thanks
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Re: Query problem

Post by patrikG »

Try

Code: Select all

$query = "SELECT DISTINCT Lesson.lesson_name, Lesson.title, Lesson.content, Images.imageinfo, Images.description
				FROM Lesson, Images WHERE Lesson.lesson_id = '$LESSON' 
AND Images.lesson_id = '$LESSON'";
chiching72
Forum Newbie
Posts: 3
Joined: Tue Jun 26, 2007 8:40 pm

Re: Query problem

Post by chiching72 »

nope, it still gives me two results (duplicate)...
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

Are you sure 'lesson_id' is unique in your tables?
Post Reply