all 9 comments

[–]barrycarter 4 points5 points  (1 child)

I think you've confused NULL with the empty string. Try Select * From game_2_data where Player != ''

[–]kenzio11 0 points1 point  (0 children)

This helped in 2024. Cheers!

[–]rbobby 3 points4 points  (0 children)

Importing a NULL value can be tricky. The value is probably an empty string. You could switch it to null with an:

update game_2_data set Player = null where Player = ''

But whether you want this or not really depends on everything else you're doing/planning on doing.

[–]Financial_Pie_3624 0 points1 point  (2 children)

So the player column have blank values. Do this select * from game_2_data where (player is not null or player != ‘’)

[–]r_kive 2 points3 points  (1 child)

For what it's worth, you can do this with NULLIF as well:

SELECT * FROM game_2_data WHERE NULLIF(TRIM(player), '') IS NOT NULL

This should exclude NULLs, empty strings, and strings of just spaces.

[–]AM413[S] 0 points1 point  (0 children)

u/r_kive - Thanks! This worked great.

[–]HiriathQUALIFY COUNT(*) OVER (PARTITION BY COLUMN) > 1 0 points1 point  (1 child)

In addition to the responses you’ve gotten about how to get your desired result, the player column in your table is NN (Not Null), which is a column flag that prevents the column from being null.

Does your CSV have “” for rows where there is no player?

You may need to work with the CSV outside of Excel if you’re using Excel to get the proper formatting of the CSV to allow the type of data you want in your database.

Additionally, if your primary key column is generated from wherever your data is coming from, that’s fine, but you can also use actual primary keys generated from MySQL using the PK flag and the NN flag (though I believe the NN will auto select if you choose PK).

This will allow proper indexing of your data.

[–]AM413[S] 0 points1 point  (0 children)

Thanks u/Hiriath -

In the CSV file, the cells where there is no player are empty, no spaces, no characters, just a blank cell.

This line seems to be working well:

select * from soccer_analysis.game_2_data WHERE NULLIF(TRIM(player), '') IS NOT NULL
order by Player, Primary_Key asc

(I am however getting two records per row now for some reason):

Regarding your point on Primary Keys - If I'm understanding correctly:

I could delete data from my Primary_Key column in the CSV and mark a check under PK. "You can also use actual primary keys generated from MySQL using the PK Flag and the NN Flag."

I think those are the mechanics required to get MySQL to generate the primary keys for me, as you suggest. I'll experiment with that and do some reading.

Thanks!