Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
winky3d
- Forum Newbie
- Posts: 9
- Joined: Thu Apr 26, 2007 1:37 pm
Post
by winky3d »
I'm trying to retrieve all the columns in any rows that fall between a date range and have distinct emails...
Code: Select all
sql_query("SELECT DISTINCT `email` FROM "._MY_TABLE." WHERE ts BETWEEN '$startdate' AND '$enddate'");
The above works, but only returns the email column for each row.
How can I can all the columns for each row?
thx.
-
John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
-
Contact:
Post
by John Cartwright »
swap the distinct for a GROUP BY email clause
-
winky3d
- Forum Newbie
- Posts: 9
- Joined: Thu Apr 26, 2007 1:37 pm
Post
by winky3d »
Great, thanks.
-
winky3d
- Forum Newbie
- Posts: 9
- Joined: Thu Apr 26, 2007 1:37 pm
Post
by winky3d »
Still having trouble...
This only returns one result:
Code: Select all
SELECT COUNT(*) FROM "._MY_TABLE." WHERE ts BETWEEN '$startdate' AND '$enddate' GROUP BY email HAVING COUNT(*) < 2
How can I return all the results where email is unique?
-
winky3d
- Forum Newbie
- Posts: 9
- Joined: Thu Apr 26, 2007 1:37 pm
Post
by winky3d »
For the rest of us noobs... This works
Code: Select all
"SELECT email, COUNT(*) FROM "._MY_TABLE." WHERE ts BETWEEN '$startdate' AND '$enddate' GROUP BY email"