Help with MySQL syntax

OfWolfAndManOfWolfAndMan Member Posts: 923 ■■■■□□□□□□
So I am new to SQL and using it for something at work.

I have the following table I made:

CREATE TABLE PC_Contacts
(
POC VARCHAR(255) PRIMARY KEY NOT NULL,
Phone_1 VARCHAR(255),
Phone_2 VARCHAR(255)
);

I import some data from a CSV into the table using the following command in powershell:
cmd /c 'mysql -u root -p network < CSVImport.sql'

After populating the table, something I noticed is when the last column (Phone_2) doesn't have a phone number populated, instead of inputting a NULL value, it is blank. In addition, several characters on the POC column are cut off whenever a phone number is omitted. So I input xxx-xxx-xxxx into the columns, repopulated it, and everything looked clean. How can I make it so I don't have to do this and the table can just populate itself with NULL values?

+
+
+
| POC | Phone_1 | Phone_2
+
+
+
|April Wilson| 123-456-7890 | xxx-xxx-xxxx
|Anton Watson | 234-567-8901| 567-890-1234
|Ashley Walker | 345-678-9012 | 456-789-0123

Names and phone have been altered, of course :).
:study:Reading: Lab Books, Ansible Documentation, Python Cookbook 2018 Goals: More Ansible/Python work for Automation, IPSpace Automation Course [X], Build Jenkins Framework for Network Automation []

Comments

Sign In or Register to comment.