sql-insert

Inserting multiple rows into table - getting error ORA-00933: SQL command not properly ended

白昼怎懂夜的黑 提交于 2021-02-11 18:12:15
问题 create table employee ( employee_id number (5), first_name varchar2(100), last_name varchar2(100), salary number (10), department_id number(5), hire_date date, constraint pk_emp primary key (employee_id) ) insert into employee (employee_id, last_name, salary ) values (129, 'khaj', 19000), (130, 'ravi', 20000); enter image description here 回答1: Wrong syntax. Either insert into employee (employee_id, last_name, salary) values (129, 'khaj', 19000); insert into employee (employee_id, last_name,

SQL Server - all possible combinations of Bit columns

谁说胖子不能爱 提交于 2021-02-11 13:32:49
问题 I have an empty table with 7 BIT columns (A, B, C, D, E, F, and G). I am looking to populate this table with rows representing all possible combinations of these columns. Ideally there would be no rows containing duplicates of the exact same combinations. Although I am showing 7 columns here, the number of columns could be greater, so the solution should be scalable. A snippet of the table after being populated would look similar to below: Ideally this would be based on an INSERT statement,

Creating a stored procedure which ingests data after reading a JSON string

♀尐吖头ヾ 提交于 2021-02-11 12:15:25
问题 I would like to create a stored procedure, in SQL Server, that can accept JSON data and upload it into a specified table into its relevant columns. For instance, take this JSON string: [{"ID":5,"LastName":"Donalds","FirstName":"Dave","Age":23,"City":"London"}] This above string can be produced with the following query: SELECT 5 as 'ID', 'Donalds' as 'LastName', 'Dave' as 'FirstName', 23 as 'Age', 'London' as 'City' FOR JSON PATH I've managed to write a script which can upload into my table

MySQL Query, problems with with duplicates on insert into

拈花ヽ惹草 提交于 2021-02-11 12:14:06
问题 So I'm using the forum software Xenforo and I need help with a SQL query which will be executed periodically. The forum will have approximately 300-500 active users. So nothing too big. The goal: All users xf_users need to be subscribed to node_id 71 except users which are part of certain user_group_id . Now users can unsubscribe from the forum or change the notify_on and send_alert & send_email fields. I do not want that. So if users 'unsubscribe' they need to be added again. The only

Creating a stored procedure which ingests data after reading a JSON string

好久不见. 提交于 2021-02-11 12:13:55
问题 I would like to create a stored procedure, in SQL Server, that can accept JSON data and upload it into a specified table into its relevant columns. For instance, take this JSON string: [{"ID":5,"LastName":"Donalds","FirstName":"Dave","Age":23,"City":"London"}] This above string can be produced with the following query: SELECT 5 as 'ID', 'Donalds' as 'LastName', 'Dave' as 'FirstName', 23 as 'Age', 'London' as 'City' FOR JSON PATH I've managed to write a script which can upload into my table

How to check if element exists in database and return a warning message?

落爺英雄遲暮 提交于 2021-02-10 19:52:26
问题 I have a case where I am importing a spreadsheet of items, and when inserting I need to check for each item if already exists (either by serial_no or serial_imei) and then for each that EXISTS I need to inform the user when the submission is done with a message such as: "Item with serial no 123456 was already found in database". Here is the way I am inserting: $stmt = $db->prepare("INSERT INTO devices (serial_imei,serial_no) VALUES (?,?)"); for ($i = 0; $i < $min; $i++) { $stmt->bind_param(

Spring Boot JPA Insert and Update

◇◆丶佛笑我妖孽 提交于 2021-02-10 12:47:46
问题 Alright, I've looked around to find this answer for about an hour and I can't see it posted. So I bought the Spring Framework Master Class from in28minutes on Udemy. We have started implementing JPA. However, the Spring Boot versions are different( he is using 2.0.3, I am using 2.4.0). Now I know that's the issue. So the task is to simply connect to a h2 database, and interact with the data. Here is the current code setup I am using: JpaDemoApplication.java package com.in28minutes.database

Spring Boot JPA Insert and Update

自闭症网瘾萝莉.ら 提交于 2021-02-10 12:44:09
问题 Alright, I've looked around to find this answer for about an hour and I can't see it posted. So I bought the Spring Framework Master Class from in28minutes on Udemy. We have started implementing JPA. However, the Spring Boot versions are different( he is using 2.0.3, I am using 2.4.0). Now I know that's the issue. So the task is to simply connect to a h2 database, and interact with the data. Here is the current code setup I am using: JpaDemoApplication.java package com.in28minutes.database

Spring Boot JPA Insert and Update

柔情痞子 提交于 2021-02-10 12:43:13
问题 Alright, I've looked around to find this answer for about an hour and I can't see it posted. So I bought the Spring Framework Master Class from in28minutes on Udemy. We have started implementing JPA. However, the Spring Boot versions are different( he is using 2.0.3, I am using 2.4.0). Now I know that's the issue. So the task is to simply connect to a h2 database, and interact with the data. Here is the current code setup I am using: JpaDemoApplication.java package com.in28minutes.database

Is the order of inserts specified for INSERT IGNORE … SELECT?

旧巷老猫 提交于 2021-02-08 09:48:39
问题 I have a table like: CREATE TABLE { email VARCHAR PRIMARY, last_login DATE } And I can populate with a select result set like: ("a@b.c", "2019-01-01"), ("a@b.c", "2019-02-01") If I will insert into that table using INSERT IGNORE ... SELECT , is it specified which row gets inserted and which is ignored? Found specification: "Specify IGNORE to ignore rows that would cause duplicate-key violations." from https://dev.mysql.com/doc/refman/5.5/en/insert-select.html. But this does not say which is