所有问题: [insert]
302 个问题
MySQL-表锁定与行锁定
应用说明 我有一张表格,其中存储有代表地图上区域的ID。每个地图包含1000个区域。 地区是指触摸中的任意数量的地图区域。用户争夺地图不同区域的所有权。 数据库设计 目前,我有一张地图,一张领土表和一张面积表。 tblMaps: MapID, MapName tblTerritories: TerrID (unique game wide), MapID, OwnerID, Status, Modified tblAreas: AreaID (1-1000), TerrID 目前,tblAreas仅在地图内存储占用区域-不管是否有人拥有,每个地图都不会包含...
如何在不为非自动增量主键指定值的情况下插入数据?
我有这张桌子: CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) ) 1. insert into persons values (1, 'John', 'Smith', 'LA', 'LA'); 2. insert into persons (p_id, lastname, firstname, address, c...
插入触发器(SQL 2005)
我有一个临时表(question_desc, ans1, ans2, ans3, ans4, correct_ans, marks),上面有10个条目。 在此表中,我必须在其他两个表中插入值: questions (q_id(auto-generated), que_desc, marks) answers (ans_id(auto_generated), q_id(FK), ans_desc, istrue) 对于questions表中的每个插入,在answers表中应有四个插入,并将istrue位设置为1,以得到正确答案。 就像问题1与corr_ans 1一样,将有...
MySQL-防止重复预定
我正在尝试找出最好的方法来停止应用程序中的两次“预订”。 我有一个唯一ID表,每个表只能出售一次。 我当前的想法是使用事务检查所选产品是否可用,然后将其插入到“状态”列中以表示已被“保留”,然后插入“更新时间”,然后用户继续付款,我将状态更新为“已售”。 每10分钟,我都会进行一次cron作业检查,以检查“状态” =“保留”,该检查已在10多分钟前更新,并删除了此类行。 有更好的方法吗?我从未使用过交易(我刚刚听到过这样的词),所以如果有人可以解释我将如何做到这一点,那将是王牌。
MySQL-插入三个表
我最近问了这个问题。 我有一个包含三个表的关系数据库。第一个包含ID的 与第二个有关。第二 包含与 第三。第三个包含结果 我在追。 是否可以通过单个查询来 在第一个表中查询一个ID 给出第三张表的所有结果 与此有关? 我选择的解决方案是: 从table1 t1选择*加入table2 t2 在t1.t2ref = t2.id上加入table3 t3 t2.t3ref = t3.id 添加where子句以搜索 table1中的某些行 其中t1.field ='v...
使用uniqueidentifier作为主键,并使用参数化查询将其从客户端应用程序插入
我创建了一个数据库,在其中使用uniqueidentifier作为主键。我正在尝试运行最终看起来像这样的参数化查询。 (插入someTable(uniqueID)值('76c14693-5475-4224-ba94-7d30c919ac59')(uniqueID是我的PK)。当我在SQL Server Management Studio中运行它时,此插入语句执行没有问题,但是,当我运行时,它会失败尝试从我的代码中运行它。 错误:当IDENTITY_INSERT设置为OFF时,无法为表'someTable'中的标识列插入显式值。 我进行了查找,关于打开IDENTITY_INSERT的...
将值插入SQL Server
我想在SQL Server中插入值,但是有一个问题是我在参数中同时传递了两个值,如果我选择一个值,则不会以其他方式插入,然后插入数据库名称是sample而表是item 这是否是完美的插入语句? try { int val = stmt.executeUpdate("INSERT item (patientid,itemid) VALUES(nPatientID," + LrBn.TestID+ ")"); out.println("1 row affected"); } catch (SQLException s) { System.out.println(...
MySQL INSERT INTO / ON DUPLICATE KEY与SELECT语句问题
你好-我是MySQL Noob。我有一张各种商家信息的表格,我试图填充第二个表格,称为城市,其中包含唯一的城市名称以及每个城市的列表数量。我可以执行SELECT语句,使我的数据像这样: SELECT city,state,sum(count) FROM ( SELECT city,state, 1 AS count FROM listings ) results GROUP BY city ORDER BY sum(count) DESC,city; 但是,现在我想更新表,但是似乎无法获得正确的语句。这是我的最新消息,但当前收到“无效使用组函数”错误。 INSERT INT...
创建/附加节点与innerHTML
是否有人有充分的理由使用一个?据我所知,创建/附加节点只是防止您创建无效的代码,而innerHTML则允许您一次注入多个节点。 鉴于我需要插入几个标签,因此使用innerHTML似乎很有意义。有人有不同的看法吗?
LINQtoSQL:检查插入时是否存在行的最佳方法是什么?
我正在从Excel / CSV文件更新到数据库。我正在使用LINQ to SQL进行数据库操作。我有很多列要更新/插入,所以我想以某种方式为整个行生成一个校验和会更容易。 例如,我可以在目标表中具有相同的人[名字,姓氏,ssn,地址],但另一家公司发送的BUT,因此它们之间仅相差一个整数值);所以我想知道,是否有解决方案来确保我所有唯一行的校验和都唯一? 我是否应该以某种方式在存储过程中实现它?
jQuery将html插入子ul-tag之前的列表中
我有这个: <ul id="pickme"> <li>1</li> <li>2</li> <li>3 <ul> <li>3-1</li> </ul> </li> </ul> 但是想要这个: <ul id="pickme"> <li>1</li> <li>2</li> ...
PHP的mysql_insert_id多行?
是否可以从插入多行的查询中获取自动递增的ID? 例如: INSERT INTO表(col1,col2)值(1、2),(3、4),(5、6); 或者,有一种方法可以找到NEXT自动增量值,而无需在表中插入任何内容? 谢谢
SQL日期字段未完全保存
我正在尝试在SQL表格的日期时间字段中插入日期值'2010-03-14 02:00:00 AM'(2010年的夏令时开始时间)服务器2005。日期保存为'2010-03-14 03:00:00 AM'。服务器安装在美国(美国东部标准时间)。 有人可以告诉我保存日期不同的原因吗? 谢谢 鲁帕
选择MAX(field)+1 FROM ...并发问题
您好,我担心合作伙伴应用程序的并发性在最近几天一直困扰着CRUDS操作,尤其是插入操作。因此,我运行了SQL事件探查器,并注意到他的插入语句不使用事务,而且他正在使用: INSERT INTO TABLEA VALUES ( (SELECT MAX(NUMBERFIELD) +1 FROM TABLEA), ....); 如何避免使用MAX()+ 1生成主键?我建议使用自动增量或事务作用域,但他不希望或者他不知道如何实现这一目标,是否还有另一种方法可以导致这种情况? 使用SQL和C ++ 1.1 *这不是我的代码,但我可能会考虑向他展示此帖子,因为我认为他必须考虑所有意...
Java 1.4 -SQL Server 2000:无法将多个记录插入表中
插入[UPLOAD_FILE_RECORD_FIELDS_DATA]([RECORD_ID],[FIELD_ORDER],[FIELD_VALUE],[ERROR_CODE]) select ?,?,?,? union all select ?,?,?,? union all select ?,?,?,? 我必须在一张表中插入多条记录,所以我正在使用如下查询并设置参数值。但是我收到错误代码77。是什么原因? 要插入的记录数约为70000。因此,我在一个查询中插入100条记录,然后对preparestatment使用addBatch()700次,执行整个批处理。
Linq一对多插入(如果已经存在)
所以我是linq的新手,所以请注意我正在做的事情可能完全是愚蠢的! 我有一个caseStudies表和一个具有多对多关系的Services表 案例研究已经存在,我正在尝试插入服务,同时链接一些已经存在的案例研究。我以为这样的事情行得通吗? Service service = new Service() { CreateDate = DateTime.Now, CreatedBy = (from u in db.Users where u.Id == userId ...
哪个sqlite语句可以产生指示重复条目的结果?安卓
对于我的应用程序,我试图添加条目而没有重复的条目,如果存在重复的条目,则通知用户并让他再试一次。使用SQLite(我对此知之甚少),我尝试了这两种方法,并想知道哪种方法更好,效率更高或开发方法更好。 第一种方式: db.execSQL("INSERT INTO " + DatabaseHelper.DATABASE_TABLE + "(LATITUDE, LONGITUDE, RATING) SELECT " + latitude + ", " + longitude + ", " + rating + " WHERE NOT EXISTS (SELECT 1 FROM " + ...
Linq初学者插入问题
为什么这东西不起作用? [Database(Name="Relationships_Test")] [Table(Name = "Order")] public class Order { [Column(Name="ID", IsPrimaryKey=true)] public int ID { get; set; } [Column(Name = "OrderDate")] public DateTime OrderDate { get; set; } public void Save() { DataContext dc = new DataContext(...
单击按钮上的文本框添加删除<li>
我对js有问题。我有下面的表格。“添加”按钮正在与输入框一起添加li,而“删除”按钮正在被删除...。问题是,它是在ul之后创建li,而在ul之后:/您可以在下面的屏幕截图中清楚地看到它。关于解决方案有什么想法吗?欣赏!!!谢谢!!! * ps,如何命名创建的输入 独特?现在所有人都有相同的名字 txt:/ * JS代码 function addTextBox() { var form = document.contact; form.appendChild(document.createElement('li')).i...
无法将参数值从ListItem转换为String
我正在尝试使用SQL Server 2005将某些值插入表中。 我已经使用了文本框,标签和列表框。 但是这样做,我出现了一个错误,指出“无法将参数值从ListItem转换为String” 我该如何解决? try { //Create an insert command SqlCommand insertCmd = new SqlCommand("INSERT INTO Account(CustID, Name, TelExtension, Email, Password, AccountType, Status) V...
my insert query is working in my localhost but not in web server
I am using flex builder 3 to insert into mysql database using php and everything is working perfectly in my localhost, the problem is when I deploy the project in the web server and run it, it connect to the database but i can't insert data ( it shows nothing when i insert data ) another stupid t...
SQL Insert with data from multiple tables
I have four tables: Messages, MessageCategory, MessageStatus and MessageLevel. MessageCategory, MessageStatus and MessageLevel all just have three fields: Identity (primary key), Code and Description. Messages refers to these three fields and has a few other data fields, including Identity (prim...
Problem with MySql INSERT MAX()+1
I have a single table containing many users. In that table I have column called user_id (INT), which I want increment separately for each person. user_id MUST start at 1 I've prepared a simple example: Showing all names +--------------+-----------------------+ | user_id | name ...
print entire directory of text files to printer with filename as header using bash or openoffice basic script
I want to print an entire directory of text files to a printer inserting the file name at the top of the first page of each file that is printed. A bash or openoffice script would serve me well. Thanks
SQLite INSERT Statement
I have created the following insert method which works fairly well but I know it could be more efficient. Could someone show me how to convert this method to use parameters and/or increase its efficiency? public static void SQLiteTableINSERT(string tableName) { int colCount = 0; using (...
PHP MySQL inserting data to multiple tables
I'm trying to make an experimental web application which minimises redundant data. I have three example tables set up like so: Table one ID | created_at (unix timestamp) | updated_at (unix timestamp) Table two ID | Foreign Key to table one | Title Table three (pages) ID | Foreign Keys to both ...
C# SQLite Bulk Insert or Parameterized Insert Efficenecy
I have a DataTable which I want to save to a SQLite Database Table. Here is my dilemma, I don't know which way to go. At most the DataTable would contain 65,000 rows and probably 12 columns. So, would it be faster to save the DataTable to a CSV file and then Bulk Insert it into SQLite (which...
How Can I Get the Identity Column Value Associated with a SubSonic 3 LinqTemplate Insert?
I am using SubSonic 3.0.0.3 along with the Linq T4 Templates. My ProjectRepository, for example, has the following two methods: public int Add(Project item) { int result = 0; ISqlQuery query = BuildInsertQuery(item); if (query != null) { result = query.Execute(); } ...
What's the best way to extract data from a database with an update if needed?
I need to insert a data into a DB using query like this one: INSERT INTO Table1 (aID) VALUES (select aID from Table2 where aID="aID")) The problem is that if Table2 doesn’t have the aID I need to update it with it and extract the newly created ID. Is there a SQL command that automatica...