MySQL Forums
Forum List  »  MySQL Workbench

Re: I want Null not 0
Posted by: alan scott
Date: April 18, 2022 03:32PM

Quote

In these fora, enclose text whose formatting you wish to preserve inside BBCode code tags.

Will do in future.

Quote

If the spreadsheet outputs spaces for missing values and you need nulls for missing values, you could import into variables ...

load data ...
...
columns(@col0, @col1, ...)
...
set col1=if(@col1=' ',null,@col1), etc ...


... for all columns, but you'll need to write that 132 times. (See the Load Data Infile manual page for examples.)

I've done that already and as you say it's a real pain. Hence wondering if there was a way to avoid it.

Quote

That's an argument for scripting this input step in a complete language for which there's a MySQL API, eg PHP.

I've been managing my whisky collection through Excel but in my previous life I've seen the power of SQL and as a little intellectual challenge I wanted to learn My SQL and port my data over to it. Would this book be reasonable for picking up PHP? https://www.amazon.co.uk/PHP-MySQL-Server-side-Web-Development/dp/1119149223/ref=sr_1_1_sspa?crid=6WBNAKELP5E4&keywords=PHP&qid=1650316211&sprefix=php%2Caps%2C179&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyNTFWSlhQOUUyWUlHJmVuY3J5cHRlZElkPUEwNjUwMzE1M08yMEExRU1DWE0xTSZlbmNyeXB0ZWRBZElkPUEwOTE5ODQwMVBHUEUwWUpNTUE0JndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==

Quote

And if you're going to do that, and if the table here is meant as a permanent table for data analysis (rather than just sucking up spreadsheet data), consider fixing its design with something like ...

swa_averages ( bottle_id int unsigned, mo smallint unsigned, value unsigned, primary key(bottle_id,mo) )

... to dispense with the monstrosity of column names containing indexing digits.

I do want it to be permanent so I'll give your suggestion a go tomorrow. Monstrosity seems harsh but in the circumstances fair.

Quote

Finally, if you must use Notepad (ugh) for handling text files coming into or out of MySQL, be sure to set its charset to what MySQL is using.
Once my PHP is up and running I'll never look at Notebook again but in the meantime I'll check out the charsets.

Thank you for all of your help.

Options: ReplyQuote


Subject
Views
Written By
Posted
275
April 17, 2022 03:51PM
169
April 17, 2022 05:00PM
182
April 18, 2022 12:56AM
166
April 18, 2022 12:12PM
Re: I want Null not 0
171
April 18, 2022 03:32PM
147
April 18, 2022 04:46PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.