Search Results

Search found 23955 results on 959 pages for 'insert query'.

Page 92/959 | < Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >

  • get last insert id when using Activerecord

    - by pierr
    Hi, For Sqilte3 C API, I would use sqlite3_last_insert_rowid. How to get this id when using ActiveRecord after insert a new record? I use following way to insert a new record : Section.new |s| s.a = 1 s.b = 2 #I expected the return value of save to be the last_insert_id, but it is NOT s.save end

    Read the article

  • mysql subquery strangely slow

    - by aviv
    I have a query to select from another sub-query select. While the two queries look almost the same the second query (in this sample) runs much slower: SELECT user.id ,user.first_name -- user.* FROM user WHERE user.id IN (SELECT ref_id FROM education WHERE ref_type='user' AND education.institute_id='58' AND education.institute_type='1' ); This query takes 1.2s Explain on this query results: id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY user index first_name 152 141192 Using where; Using index 2 DEPENDENT SUBQUERY education index_subquery ref_type,ref_id,institute_id,institute_type,ref_type_2 ref_id 4 func 1 Using where The second query: SELECT -- user.id -- user.first_name user.* FROM user WHERE user.id IN (SELECT ref_id FROM education WHERE ref_type='user' AND education.institute_id='58' AND education.institute_type='1' ); Takes 45sec to run, with explain: id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY user ALL 141192 Using where 2 DEPENDENT SUBQUERY education index_subquery ref_type,ref_id,institute_id,institute_type,ref_type_2 ref_id 4 func 1 Using where Why is it slower if i query only by index fields? Why both queries scans the full length of the user table? Any ideas how to improve? Thanks.

    Read the article

  • Mysql replace() function, help with query (what chars do I escape?)

    - by jyoseph
    I am trying to update an old cms where images were stored in /images/editor/, they are now stored in a bucket on amazon s3. I'm trying to update the database using mysql replace. I've done this in the past with replacing simple words, but now Mysql is reporting an error, I suspect because this is more than a simple word: UPDATE contents SET desc = replace(desc, '/images/editor/', 'http://s3.amazonaws.com/my_bucket/editor/') Do I need to escape the : or slashes? I've tried escaping it with a '\' to no avail. Can someone get me pointed in the right direction? Thanks! Edit Here's the error I am getting, nothing too telling error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc = replace(desc, '/images/editor', 'http://s3.amazonaws.com/app_navigator/ed' at line 1

    Read the article

  • Where clause on joined table used for user defined key/value pairs

    - by Steve Wright
    Our application allows administrators to add “User Properties” in order for them to be able to tailor the system to match their own HR systems. For example, if your company has departments, you can define “Departments” in the Properties table and then add values that correspond to “Departments” such as “Jewelry”, “Electronics” etc… You are then able to assign a department to users. Here is the schema: In this schema, a User can have only one UserPropertyValue per Property, but doesn’t have to have a value for the property. I am trying to build a query that will be used in SSRS 2005 and also have it use the PropertyValues as the filter for users. My query looks like this: SELECT UserLogin, FirstName, LastName FROM Users U LEFT OUTER JOIN UserPropertyValues UPV ON U.ID = UPV.UserID WHERE UPV.PropertyValueID IN (1, 5) When I run this, if the user has ANY of the property values, they are returned. What I would like to have is where this query will return users that have values BY PROPERTY. So if PropertyValueID = 1 is of Department (Jewelry), and PropertyValueID = 5 is of EmploymentType (Full Time), I want to return all users that are in Department Jewelry that are EmployeeType of Full Time, can this be done? Here's a full data example: User A has Department(Jewelry value = 1) and EmploymentType(FullTime value = 5)User B has Department(Electronics value = 2) and EmploymentType(FullTime value = 5)User C has Department(Jewelry value = 1) and EmployementType(PartTime value = 6) My query should only return User A using the above query UPDATE: I should state that this query is used as a dataset in SSRS, so the parameter passed to the query will be @PropertyIDs and it is defined as a multi-value parameter in SSRS. WHERE UPV.PropertyValueID IN (@PropertyIDs)

    Read the article

  • INSERT and transaction searilization in PostreSQL

    - by Alexander
    Hello! I have a question. Transaction isolation level set to serializable. When the one user open transaction and INSERT or UPDATE data in "table1" and then another user open transaction and try to INSERT data to the same table is second user need to wait 'til the first user commits the transaction?

    Read the article

  • MySQL Math - Is it possible to calculate a correlation in a query?

    - by John M
    In a MySQL (5.1) database table there is data that represents: how long a user takes to perform a task and how many items the user handled during the task. Would MySQL support correlating the data or do I need to use PHP/C# to calcuate? Where would I find a good formula to calculate correlation (it's been a long time since I last did this)?

    Read the article

  • How to create Insert script using c#

    - by karthik
    From my c# code behind, i pass a query to mysql database and get the data in a DataTable. Now i want to use the data in data table to write the Insert query in a script file [.sql] The objective of doing so is, whatever records i select from mysql, i should write that to a script file as backup. Thais why i need the insert statements. How ? Or any other idea is appreciated.

    Read the article

  • Is there a way to simplify this Django query?

    - by Mark
    accepted_bids = Bid.objects.filter(shipment__user=u, status='acc').select_related('shipment') completed_shipments = [] for b in accepted_bids: completed_shipments.append(b.shipment) vehicles_shipped = [] for s in completed_shipments: vehicles_shipped.extend(s.items.all()) In the end, I want a list of shipped vehicles. A vehicle is shipped if it's part of a shipment that's completed. A shipment is completed if it has an accepted bid. I'd prefer not to iterate over the querysets thereby forcing a hit to the DB before its necessary... isn't there a way to get all the associated shipments from a list of bids, for example?

    Read the article

  • Boost any usage

    - by Ockonal
    Hello, how can I insert my own class objects into ptr_map from boost. The objects are templated so I can't use some static typename in the map. So I did: ptr_map<string, any> someMap; My class inherits the boost::noncopyable. someMap.insert("Test", new MyClass()); The error is: error: no matching function for call to ‘boost::ptr_map.

    Read the article

  • Using ROWLOCK in an INSERT statement (SQL Server)

    - by RPS
    Would it be wise to use ROWLOCK on an insert statement that is copying large amounts of data and inserting it into the same table? Ex) INSERT INTO TABLE with (rowlock) (id, name) SELECT newid, name FROM TABLE with (nolock) WHERE id = 1 Does anybody have recommendations on how to improve this statement, as I see when SQL Server gets busy it will end in Timeout Query returned for SQL Server.

    Read the article

  • insert a time-stamp value in my db by php

    - by Erick
    I'm using oracle express and in my application i would insert a time-stamp value in my table: $marca = date('y-m-d H:i:s'); $query = " INSERT INTO SA_VERSIONE ( ID_ACCETTAZIONE, MARCA_TEMPORALE, TESTO, FIRMA, MEDICO) VALUES ('$id', '$marca', '$testo', '$firma', '$medico') "; $stid = oci_parse($conn, $query); oci_execute($stid); but when execute it return: Warning: oci_execute() [function.oci-execute]: ORA-01843: mese non valido in ... and say that the month is not valid

    Read the article

  • Insert hex string value to sql server binary field is appending extra 0

    - by rotary_engine
    Have a binary field and want to insert into this from a hex string: insert into binaryTable(binaryField) values(convert(varbinary(max), 0x0)) however when I run select the value is return with an extra 0 as 0x00 This extra 0 is causing a problem in another application, I dont want it. Interesting, is if I do a select on an existing value and it returns say 0x55 then inserting this same value using the above query will return a select of 0x055. How to stop the extra 0 being added?

    Read the article

  • insert text in the middle of string in flex 3

    - by m6azeez
    hello all, can you please help me with this issue the String class does not have insert method it has only replace :( . what I need is: - if I have string "I stackoverflow" - I need to insert "love " at index 2 to have "I love stackoverflow" so what I need is insertAt(index, String) thanks

    Read the article

  • Insert into textarea | JavaScript

    - by Wayne
    I'm trying to insert the image url where the point of the is to be when editing the textarea value. function addImageURL() { var imageurl = prompt("Enter image URL", "Your name") var post = document.getElementById("message-put").value; document.getElementById('message-put').value = post + '[img]' + imageurl + '[/img]'; } This code grabs the value inside the adds the image url next to it which I don't want, I need it to insert it where the point was when editing the textarea Thanks

    Read the article

  • MySQL INSERT and SELECT Order of precedence

    - by Carlos Dubus
    Hi, if an INSERT and a SELECT are done simultaneously on a mysql table which one will go first? Example: Suppose "users" table row count is 0. Then this two queries are run at the same time (assume it's at the same mili/micro second): INSERT into users (id) values (1) and SELECT COUNT(*) from users Will the last query return 0 or 1?

    Read the article

  • Playframework sends 2 queries for fetched query

    - by MRu
    I currently have problems with the JPA at the play framework 1.2.4. I need to have a UserOptions model in a separate database and want to join it lazyly cause its only needed in one query. In this query I want to load the options eagerly and by searching I found out that can only be done by using a join query. If I use eager instead oder lazy, everything would be fine by using User.findById() and the options and the user is found in one query. But play sends two queries when I use a 'left join fetch' query. So heres the query: User.find(" SELECT user FROM User user LEFT JOIN FETCH user.options options WHERE user.id = ? ", Long.parseLong(id)).first(); And here the models: @Entity public class User extends Model { @OneToOne(mappedBy = "user", fetch = FetchType.LAZY) public UserOptions options; // ... } @Entity public class UserOptions extends Model { @OneToOne(fetch = FetchType.LAZY) public User user; } The question is why play sends two query for the fetch query? Thanks in advance

    Read the article

  • STL map - insert or update

    - by CodeJunkie
    I have a map of objects and I want to update the object mapped to a key, or create a new object and insert into the map. The update is done by a different function that takes a pointer to the object (void update(MyClass *obj)) What is the best way to "insert or update" an element in a map?

    Read the article

  • php date will not insert into mysql database

    - by Piers Blinco
    this is a strange one. I have a date, that is converted to mm-dd-yyyy when posting it to mysql i have re-ordered it to yyyy-mm-dd but yet it still will not insert $date = date("Y-m-d", strtotime($_POST['leaving_date']) ); any advice? Cheers EDIT The actual query: mysql_query("INSERT INTO booking_info (customer_id, booking_ref, date_of_travel) VALUES (".mysql_real_escape_string($_POST['customer_id']).", ".mysql_real_escape_string($rnd).", ".mysql_real_escape_string($date).")");

    Read the article

  • postgresql insert value in table in serial value

    - by Jesse Siu
    my database using postgresql. the table pk is uing serial value.if i want to insert a record in table, do i need type pk or it will automatic contain id. Can you give me a example about how to insert a record in dataset CREATE TABLE dataset ( id serial NOT NULL, age integer NOT NULL, name character varying(32) NOT NULL, description text NOT NULL DEFAULT ''::text CONSTRAINT dataset_pkey PRIMARY KEY (id ) )

    Read the article

  • How to insert time in SQl Derver 2005?

    - by sam
    i am creating windows application .In this i have to subtract two dates .i subtract it successfully ,i used TimeSpan to get subtracted value.But when i insert it in SQl Server 2005 db, it inserted with starting date i.e. 1/1/1900 and the calculated difference which format should i use to insert Time only? Thanks in advance

    Read the article

  • creating an insert image button in an acrobat 9 form

    - by Ross
    Hi, I am creating a pdf form in acrobat 9 pro, I would like to add a button so the user can insert an image from their machine. I have been give a pdf where this is possible. How can I create an insert image field in my form? Is this possibly a livecycle or windows feature? I am on osx

    Read the article

  • SQL Server 2005: Insert a row in a table and update the same row

    - by vikas
    eg:table pkey --guid annualpay datefrom dateto--if null means current record percentannualincrease percent annual increase will be calculated only if there is a difference in newly inserted and previously existing last differing value. percentannualincrease = ([newannualpay-just previous pay(if different from current)]/newannualpay)*100 eg newid(),5000,today,null,0--very first row newid(),5000,today+1,null(*),0 newid,5500,today+2,null(*),?????????????--> need to be calculated before insert *--insert will close the previous record by updating dateto=null to todays date How can I do this stuff in a trigger???

    Read the article

< Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >