Re: (OT) SQL query repeats
| From: | Jonathan Hilgeman | Date: | Wed, 15 Aug 2001 21:21:26 +0000 |
| Subject: | Re: (OT) SQL query repeats | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-11409@lists.php.net to get a copy of this message | ||
Try one of the following:
1) Move the GROUP BY between WHERE and HAVING
-OR-
2)SELECT l.*,lg.* FROM lesson l LEFT JOIN lesson_gle lg ON lg.l_id=l.l_id
WHERE lg.glenum LIKE 'MA%' GROUP BY l.l_id ORDER BY l.l_id
- Jonathan
"Adv. Systems Design" <asd_2000@yahoo.com> wrote in message
news:20010815210154.96011.qmail@web14202.mail.yahoo.com...
I appreciate the input but it does not work...I tried
it before and just now...this is the output:
SELECT *
FROM lesson, lesson_gle
WHERE lesson.l_id = lesson_gle.l_id
HAVING lesson_gle.glenum LIKE 'MA%'
ORDER BY lesson.l_id
GROUP BY lesson.l_id
MySQL Error: You have an error in your SQL syntax near
'GROUP BY lesson.l_id ' at line 7
This script cannot continue, terminating.
Any other ideas?
Luis
> hello:
>
> I have 2 tables...lesson and lesson_gle (which holds
> repeating data for lesson, i.e. l_id, glenum)
>
> the following query gets results, but there are
> repeated entries (one for every repeat in lesson_gle
> table)
>
> SELECT *
> FROM lesson, lesson_gle
> WHERE lesson.l_id = lesson_gle.l_id
> HAVING lesson_gle.glenum LIKE 'MA%'
> ORDER BY lesson.l_id
>
> Any ideas on how to get the data to not repeat?
>
> Thanks
>
> Luis
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/