sql-insert

Should I trim values in SQL or ColdFusion?

淺唱寂寞╮ 提交于 2020-02-25 05:24:16
问题 I have done many inserts/updates and question that always was on the top of my mind is where I should trim the values that I'm inserting or updating. In this case I use ColdFusion as my server-side programming language and SQL Microsoft is my database language. So if I'm doing insert, should I trim the values in ColdFusion or SQL? Do I have to do in both? What is more efficient? I was wondering if this can improve efficiency if I follow some recommended steps. Here is example that I have in

Insert nested JSON array as parameter in php mysql database

∥☆過路亽.° 提交于 2020-02-08 09:16:42
问题 I want to insert JSON parameters in my phpmyadmin database. I tried with below code but it didn't work. Kindly help me in this. my JSON parameters are: `$ "address" = "bharuch" "customer_id" = "108" "products" = "[{"product_id":"1","product_name":"Potato","category_id":"1","subcategory_id":"1","product_memberprice":"11","product_nonmemberprice":"14","product_minquantity":"500 gms","product_image":"http:\/\/gaubharat.in\/gaubharat\/images\/potato.png","product_brand":"","sub_total":"28","user

T-SQL Delete Inserted Records

↘锁芯ラ 提交于 2020-02-01 04:18:35
问题 I know the title may seem strange but this is what I want to do: I have table with many records. I want to get some of this records and insert them in other table. Something like this: INSERT INTO TableNew SELECT * FROM TableOld WHERE ... The tricky part is that I want this rows that I have inserted to be deleted form the origin table as well. Is there a easy way to do this, because the only think that I have managed to do is to use a temporary table for saving the selected records and then

T-SQL Delete Inserted Records

与世无争的帅哥 提交于 2020-02-01 04:17:25
问题 I know the title may seem strange but this is what I want to do: I have table with many records. I want to get some of this records and insert them in other table. Something like this: INSERT INTO TableNew SELECT * FROM TableOld WHERE ... The tricky part is that I want this rows that I have inserted to be deleted form the origin table as well. Is there a easy way to do this, because the only think that I have managed to do is to use a temporary table for saving the selected records and then

Adding a constraint to prevent duplicates in SQL Update Trigger

▼魔方 西西 提交于 2020-01-30 09:15:14
问题 We have a user table, every user has an unique email and username. We try to do this within our code but we want to be sure users are never inserted (or updated) in the database with the same username of email. I've added a BEFORE INSERT Trigger which prevents the insertion of duplicate users. CREATE TRIGGER [dbo].[BeforeUpdateUser] ON [dbo].[Users] INSTEAD OF INSERT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON;

Can INSERT […] ON CONFLICT be used for foreign key violations?

为君一笑 提交于 2020-01-19 06:08:38
问题 Given => select * from referenced; referenced_id | name ---------------+------- 1 | one 2 | two 3 | three and => select * from entries; entry_id | referenced_id | name ----------+---------------+------------------ 1 | 3 | references three where referenced_id and entry_id are primary keys. I want an insert statement for entries that skips insertion if either the entry_id already exists or the referenced item does not exist. The first is easily done: INSERT INTO entries VALUES (1, 2,

Can INSERT […] ON CONFLICT be used for foreign key violations?

雨燕双飞 提交于 2020-01-19 06:05:16
问题 Given => select * from referenced; referenced_id | name ---------------+------- 1 | one 2 | two 3 | three and => select * from entries; entry_id | referenced_id | name ----------+---------------+------------------ 1 | 3 | references three where referenced_id and entry_id are primary keys. I want an insert statement for entries that skips insertion if either the entry_id already exists or the referenced item does not exist. The first is easily done: INSERT INTO entries VALUES (1, 2,

Can INSERT […] ON CONFLICT be used for foreign key violations?

杀马特。学长 韩版系。学妹 提交于 2020-01-19 06:04:46
问题 Given => select * from referenced; referenced_id | name ---------------+------- 1 | one 2 | two 3 | three and => select * from entries; entry_id | referenced_id | name ----------+---------------+------------------ 1 | 3 | references three where referenced_id and entry_id are primary keys. I want an insert statement for entries that skips insertion if either the entry_id already exists or the referenced item does not exist. The first is easily done: INSERT INTO entries VALUES (1, 2,

When creating a multi row entry I get the error: Could not take attendence Unknown column '‘FName’' in 'field list'

岁酱吖の 提交于 2020-01-17 13:47:07
问题 I was looking at the previous questions such as unknown column in list But found it to not help in my case. I have a form that will take the attendance(which is calling the names and classes from my database table 'records' and is inserting it into the table called 'attendence'. My issue is when inserting into the database it turns up to be blank. Any ideas? My code: attendence-form.php <?php include( "dbconfig.php"); session_start(); if(!isset($_SESSION[ 'login_user'])) { header( "Location:

In MySQL, how can I use the autoincrement value in another column at the time of the INSERT?

社会主义新天地 提交于 2020-01-15 14:27:50
问题 I am looking to have the automagically set autoincrement included in another column during the insert. For example in a table where ID is the autoincrement and Name is the other column, I'd like to do something like `INSERT INTO Names (Name) VALUES (CONCAT("I am number ",ID));` Currently, I do the INSERT without Name, then I have to immediately after do an UPDATE using $mysqli->insert_id. I don't want to query the table in advance because, as small a time as it may be, another record could