INSERT INTO fails with node-mysql

Pay attention to the documentation of node-mysql: If you paid attention, you may have noticed that this escaping allows you to do neat things like this: var post = {id: 1, title: ‘Hello MySQL’}; var query = connection.query(‘INSERT INTO posts SET ?’, post, function(err, result) { // Neat! }); console.log(query.sql); // INSERT INTO posts SET … Read more

How does COPY work and why is it so much faster than INSERT?

There are a number of factors at work here: Network latency and round-trip delays Per-statement overheads in PostgreSQL Context switches and scheduler delays COMMIT costs, if for people doing one commit per insert (you aren’t) COPY-specific optimisations for bulk loading Network latency If the server is remote, you might be “paying” a per-statement fixed time … Read more

“column not allowed here” error in INSERT statement

You’re missing quotes around the first value, it should be INSERT INTO LOCATION VALUES(‘PQ95VM’, ‘HAPPY_STREET’, ‘FRANCE’); Incidentally, you’d be well-advised to specify the column names explicitly in the INSERT, for reasons of readability, maintainability and robustness, i.e. INSERT INTO LOCATION (POSTCODE, STREET_NAME, CITY) VALUES (‘PQ95VM’, ‘HAPPY_STREET’, ‘FRANCE’);

MySQL, how to insert null dates

Try this: $query = “INSERT INTO table (column_s1, column_s2, column_d1, column_d2) VALUES (‘$string1’, ‘$string2’, ” . ($date1==NULL ? “NULL” : “‘$date1′”) . “, ” . ($date2==NULL ? “NULL” : “‘$date2′”) . “);”; so for example if you put this into query: $string1 = “s1”; $string2 = “s2”; $date1 = NULL; $date2 = NULL; result should … Read more

How to create and insert a JSON object using MySQL queries?

On creating table set your field as JSON datatype. CREATE TABLE `person` ( `name` json DEFAULT NULL ); And Insert JSON data into it, INSERT INTO `person` (`name`) VALUES (‘[“name1”, “name2”, “name3”]’); Or Insert JSON data by Key:Value INSERT INTO person VALUES (‘{“pid”: 101, “name”: “name1”}’); INSERT INTO person VALUES (‘{“pid”: 102, “name”: “name2”}’); Select … Read more

Why I am getting an error when using w3school tutorial? [duplicate]

Warning: Never ever refer to w3schools for learning purposes. They have so many mistakes in their tutorials. According to the mysqli_query documentation, the first parameter must be a connection string: $link = mysqli_connect(“localhost”,”root”,””,”web_table”); mysqli_query($link,”INSERT INTO web_formitem (`ID`, `formID`, `caption`, `key`, `sortorder`, `type`, `enabled`, `mandatory`, `data`) VALUES (105, 7, ‘Tip izdelka (6)’, ‘producttype_6’, 42, 5, 1, … Read more