MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 13th, 2013, 09:08 AM
walfredocreativ walfredocreativ is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 3 walfredocreativ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 3 sec
Reputation Power: 0
PHP-General - Not showing duplicate last names in my database

Hi everyone,

This is probably a pretty easy question/solution but I couldnt figure it out so I had to ask for help...

I have a php mysql database at (www dot homebasebuffalo dot com) which lists area highschool athletes who have gone on to college or professional programs. The problem I realized is that I am ordering them by last name in the database - and it is not allowing for Duplicate last names. So if there are 5 'Smiths' (all different people with different info in the rest of the table) it will only show one.

Is there a simple and or not so simple way of fixing this??

Reply With Quote
  #2  
Old February 13th, 2013, 09:18 AM
NotionCommotion NotionCommotion is offline
Contributing User
Click here for more information.
 
Join Date: Sep 2006
Posts: 1,464 NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 6 h 21 m 9 sec
Reputation Power: 526
It probably has to do with your SQL query and not PHP. Check your query and see if it includes the DISTINCT key word.

Reply With Quote
  #3  
Old February 13th, 2013, 09:59 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,369 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 14 m 57 sec
Reputation Power: 4140
pro tip for getting help with a mysql query: show your query
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #4  
Old February 13th, 2013, 10:59 AM
walfredocreativ walfredocreativ is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 3 walfredocreativ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 3 sec
Reputation Power: 0
It seems to be happening when I import my .csv into the MYsql ... its not importing duplicate last names (it has no problem importing duplicate other fields)

my query is ...

$sql = "SELECT * FROM main ORDER BY last";

So I dont think its in the mysql query as much as the import. Does it matter that my "last" field is set to primary?

Reply With Quote
  #5  
Old February 13th, 2013, 11:05 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,369 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 14 m 57 sec
Reputation Power: 4140
Quote:
Originally Posted by walfredocreativ
Does it matter that my "last" field is set to primary?
yup

primary keys are unique by definition

please do a SHOW CREATE TABLE and i'll help you fix it

Reply With Quote
  #6  
Old February 13th, 2013, 11:59 AM
walfredocreativ walfredocreativ is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 3 walfredocreativ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 3 sec
Reputation Power: 0
while googling how to do a SHOW CREATE TABLE I ended up just changing the primary field and it now is uploading perfectly. Thank you very much for the help. Sometimes its the little simple things that can be hardest to find fixes to.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > PHP-General - Not showing duplicate last names in my database

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap