/    Sign up×
Community /Pin to ProfileBookmark

mySQL Query Problem….

I know this is not really PHP, but mySQL and PHP kind of go hand in hand.

I’ve got 2 tables I’m joining together. One is a table for events, the other the dates for the events. One event may have many dates, but each date only has 1 event. Somewhat simple.

The problem after I join them, is if I select an event, it will display the same event several times. I’m only joining the dates so that I can narrow search results, but it will select event 2 or 3 times if it has 2 or 3 dates. How can I join so that it will only select the date one time.

Here is my query.

[CODE]SELECT *
FROM cvb_events LEFT JOIN cvb_events_dates on cvb_events.id = cvb_events_dates.event_id
WHERE ((title like ‘%$text%’) OR (description like ‘%$text%’)) AND (cvb_events.venue_id = ‘$venue_id’)[/CODE]

If I need to supply more information, just let me know.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderFeb 07.2007 — Maybe you need to use

[CODE]GROUP BY cvb_events_dates.event_id[/CODE]

Or use LIMIT?
×

Success!

Help @jesseainskeep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...