February 13th, 2013, 10:08 AM
Not showing duplicate last names in my database
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??
February 13th, 2013, 10:18 AM
It probably has to do with your SQL query and not PHP. Check your query and see if it includes the DISTINCT key word.
February 13th, 2013, 10:59 AM
pro tip for getting help with a mysql query: show your query
February 13th, 2013, 11:59 AM
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?
February 13th, 2013, 12:05 PM
Originally Posted by walfredocreativ
primary keys are unique by definition
please do a SHOW CREATE TABLE and i'll help you fix it
February 13th, 2013, 12:59 PM
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.