Hello Everyone,
I would like you to assist me in solving this problem I am having extracting data from MYSQL with PHP.
I have a table in my database as seen below, I am attempting to select all the Client_id that are associated with the Project_id of '20'.
ID | Client_id | Project_id
1 | 1007 | 20
2 | 1009 | 20
3 | 1010 | 16
4 | 1007 | 20
5 | 1007 | 15
6 | 1007 | 20
7 | 1009 | 16
8 | 1007 | 20
9 | 1010 | 20
10 | 1007 | 16
I have written a select statement that looped through and extract the Client_id that relates to Project 20 with the following results: (SELECT Client_id FROM Table WHERE Project_id = 20)
1007
1009
1007
1007
1007
1010
However, I would like each Client_id that associates with '20' to only be outputted once instead of everytime they appeared , for example:
1007
1009
1010
Kindly assist me since I have been at this for more than a week.
Thanks
Dave
HELP with SELECTING record FROM MySQL
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: HELP with SELECTING record FROM MySQL
I have discovered as I have gotten better at MySQL that if I get more then one record returned that I did not correctly write my query.
With 33 posts you should be aware by now that it's also pointless to post about code without posting code.
With 33 posts you should be aware by now that it's also pointless to post about code without posting code.
Re: HELP with SELECTING record FROM MySQL
+
[sql]GROUP BY Client_id[/sql]
[sql]GROUP BY Client_id[/sql]
There are 10 types of people in this world, those who understand binary and those who don't