Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Old Records Re-appear On Insert


insert into tablname (col1,col2,...) values ('value1','value2',...);
I am developping, so sometimes I delete all the contents of the table and start all over again.
What happens is this:
when I insert a value in col1 that was deleted before from the table it inserts the new value AND the old value. One of the columns is a datetime that tells me the exact insert date (in the past!!). The new record has the correct insertion datetime. So now I have two records (sometimes even more, if I used the value more often before), the old one and the new one! What's going on?




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Insert Between Two Records
as to how to insert between two specific records in mysql it is not at the bottom to be appended.
what is the syntax.

View Replies !   View Related
Insert Records
I have 2 tables namely Professors and Subjects, i want to insert data of professors to Professors table and data of subjects related to particular professor to Subjects table. How do i insert values into multiple or related tables?

View Replies !   View Related
MySql Insert Between Two Records
How can i Insert a row in between.

e.g.
+----+------------+
| Id | Name |
+----+------------+
| 1 | James Bond |
| 2 | John Doe |
+----+------------+

I want to inset a row in between the two entry. but it will be in a larger scale database, like rows in millions.

View Replies !   View Related
Insert Or Update Records
What's the best way to achieve this?
To simplify the problem, lets say I have a table with two columns, 'id' and 'value'.
Now, I want to pass an object through remoting (amfphp, irrelevant really but anyway) to either update existing rows or insert new ones.
The object I'm passing has corresponding fields, and if there is a match on the 'id' field then update it, if not insert a new row.
So I guess I need to first pull out all of the id's and compare them to the ones in my object, then seperate them up to ones that need updating, and ones that need inserting.
I can't quite see what the best way of doing this is. Either in code e.g. PHP or is there a MySQL statement to do it the quick way?

View Replies !   View Related
How To Insert Same Value To A Series Of Records
i have a table 'sip' (id,keyword,data,flags). i have a few records which need to have the id as 0 (meaning they r common for all users who register). i can enter these manually into the dB.

While entering the details of the users who register, i shd have a particular 'id' value begining with '1', for each user. (since 0 has already been taken by the previous common records).

The problem is: each user has a set of 3 records to be inserted. So, the 'id' needs to be set to '1' for 3 records (every user). then to '2' for the next 3 records and so on..

View Replies !   View Related
Bulk Insert Of New Records In Sequence
I am looking to create a querty that searches for the max value a field
called listnum in a table called tbl_listing and then interests 25 new
records with listnum's starting 1 higher then the max value.

ie if the highest listnum is 1000 it should insert new records with a
listnum of 1001-1024. All the other fields in the table can be blank.

Is there a simple (or not so simple) query that I can run to do this?

View Replies !   View Related
Insert Copied Records Using MS Access
I've been using MS Access as a front end to our remote MySQL db for a
long time. I've just added a facility for clients to select a record to copy along
with all its sub-records.

The initial record copies accross ok, but I seem to be having a spot of
bother getting the sql syntax to work. I keep getting an ODBC error
3146 ? Code:

View Replies !   View Related
MySQL Insert Records Using MS Access
I have a MySQL database linked to an MS Access front-end.

I have an app which works fine with the local copy of the Access DB,
but when run with the linked tables for MySQL, it fails.

I'm trying to copy over related data for products, which is held in
seperate tables.

The main copying of the producy works fine, just not any related
product data. Code:

View Replies !   View Related
Multiple Insert, Unique Records Only
I want to insert lets say 100 records into a db that looks like the following:

ID auto increment
IPAddress varchar

The query I am running inserts all 100 with one trip to the DB using php. What happens If I only want

Now lets say I do not want more than 1 IP in this database. Surely I don't have to search the whole database looking to see if there is a match for IPAddress.

View Replies !   View Related
Auto Increment :: Insert A Row Between Records?
Is there a way i can insert a row between records?

View Replies !   View Related
Most Effecient Way To Insert Multiple Records
i have some areas on my site where i'm inserting hundreds of records.

currently i'm looping through each record and performing the insert. something like...

PHP Code:

foreach ($records as $record) {     // insert into mysql}

is there a more efficient way of doing this? can i not send all of the records at once to mysql? like a transaction-type thing?

View Replies !   View Related
Insert Records To Remote Mysql Server
for a insert statement, there are two packets on the network between the client and the server. so, the packet's number will be double of the number of insert statement. that is rough.

I want there will be a few packet used for many many insert statement. Is there any way to make that true.

View Replies !   View Related
Insert Table Records Without Typing Query?
I'm a MySQL newbie but no stranger to Microsoft SQL Server. I'm primarily used to using Microsoft SQL Server via SQL Enterprise Studio, so I'm liking the MySQL Administrator GUI as it has a familiar feel to it.

One question (so far): in SQL Enterprise Studio, I could open a database table and insert a record simply by typing in the GUI grid (or by pasting a record from my clipboard). In MySQL Administrator, I don't see a way to do that. Is it not even possible? If not, I'll stop looking - but if there is a way to do so, I'd love to know.

For example, I'd like to be able to copy a record from an Access database or even an Excel file, and paste it into a MySQL table - not have to write an insert query and execute it.

View Replies !   View Related
Mysql Insert Records In The Middle Of Database Table
I have a table with field serial number(slno double).

I have data like this:
slno
-----
1
2
3
4

Now I want to insert a record between 3 and 4, so that the new record should have the number 5 . How to implement this? Same case with deleting a record also.

View Replies !   View Related
Lock Tables To Update And Delete, But Insert New Records
I'm trying to "lock" mysql tables - to prevent rows being updated/deleted - I still want to be able to insert new rows (legal reasons).

I have toyed with the idea of changing the user permissions - can I simply change it so that no-one can perform an update on that table, even root? But I feel there must be a simpler way that I and my many web searches am missing.

View Replies !   View Related
How To Insert New Records Based On Previous Record Values?
I have
TABLE:

year
value

It has for example,

year, code, vlaue
2007, 33, 4883
2006, 33, 4883
2007, 32, 4883
2006, 32, 4883
2008, 31, 4883
2007, 31, 4883
2006, 31, 4883

I want to insert new records for for 2008 for all codes that do not already have a record for 2008 and increase the value for the 2008 record by 3%.

My several attempts have led to this but which does not work.

UPDATE TABLE a
SET a.value = b.value * 1.05
WHERE b.year = 2007
AND code NOT IN
(SELECT code
FROM TABLE b
WHERE year =2008
AND value !=0)

View Replies !   View Related
Is There A Simple (!) Way To Auto-generate And Insert 10000 Sample Records Into A Table?
I want to test the response times and performance of MySQL DB with a large table.
For this I need a way to insert thousands of automatically generated records into
a previously created table.

Is there an easy way to achieve this?

Is there a script feature which let me do something similar like

For i=1 to 100000 DO (
INSERT INTO TAB234 VALUES (i, randomNum(1,10), randomChar('a','z', length=12), 'ALWAYSTHISTEXT') )

View Replies !   View Related
Selecting Records Belonging To Multiple Records Through Join Table
I have is 3 tables, 'categories', 'levels' and 'categories_levels', the 'categories_levels' table is a join table, with the `id`, `category_id` and `level_id` fields. Categories can belong to many different levels, so records in the join table might look like this (assuming that the category has an ID of 5)

id, category_id, level_id
1, 5, 1
2, 5, 2
3, 5, 3

So you can see that category 5 belongs to 3 different levels (1, 2, and 3).

On a web page, I've got a multiple select box, which allows a user to filter the categories depending on which levels they belong to. What I need a query to do is use that join table to find all categories which belong to the selected levels. Now for the tricky bit. Only the categories which belong to every single selected level should be displayed. So in the example above, if I select level 1, then category 5 will be displayed, but if I select levels 1 and 4, then category 5 should not be displayed, because although it does belong to level 1, it doesn't belong to level 4 as well.

View Replies !   View Related
Counting Records From Subsets Of Records Returned From Query
I am trying to figure out how to count a subset of the records returned from a query. I have a query that returns records that fit the criteria ....

View Replies !   View Related
Selecting From 1 Table Only Records That Match Multiple Records In Another
I am having trouble writing an SQL statement to select all the records in Table-A that have multiple corresponding records in Table-B that meet a requirement.

Example: .....

View Replies !   View Related
How Do I Preserve The Leading Zeros That I Insert Into A Table As Part Of My Insert
how do i preserve the leading zeros that i insert into a table as part of my insert query?


View Replies !   View Related
Insert Multiple Rows With One Insert Stmt And Nested Select
I'm trying to insert several rows into a table using only one insert statement:

insert into component_feature values (select 3,1,sf.software_feature_id,1 from software_feature sf where sf.software_id = 1)

When I run the select statement alone, I get the result I want:

+---+---+---------------------+---+
| 3 | 1 | software_feature_id | 1 |
+---+---+---------------------+---+
| 3 | 1 | 0 | 1 |
| 3 | 1 | 1 | 1 |
| 3 | 1 | 2 | 1 |
+---+---+---------------------+---+

But when I run the complete statement I get:

ERROR 1064 (42000): 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 'select 3,1,sf.software_feature_id,1 from software_feature sf where sf.software_i' at line 1

This query is part of a PHP application I'm building. I'd rather not have to write a PHP loop to do multiple inserts.

View Replies !   View Related
Mysqldump Options :: --extended-insert --complete-insert
Adding options like extended inserts or complete inserts (or both) make no difference to the output file. Why?

mysqldump -uroot -pmypass! --databases test --tables proxy_view > mytest.txt

mysqldump -uroot -pmypass! --extended-insert --complete-insert --databases test --tables proxy_view > mytest.txt

Both the commands mentioned above saves a same set of commands.

insert into tablename (column names) values (set of values), (another set of values), (one more set) Whereas I want

insert into tablename (column names) values (first set);
insert into tablename (column names) values (second set);

Ok. --skip-extended-insert is what I was looking for

View Replies !   View Related
All Records From Table A - All Records From Table B - Join Alike Records
I am by no means a SQl Jedi as will be apparent by my question, but I
can usually figure out a select statement on my own. I have one today
though that really has me stumped. I am working in MySQlL 5.

In My first select statement I get all my records from Table B
SELECT
`table_A`.`ITEM`,
`table_A`.`DECSCRIPTION`,
`table_A`.`UM`,
`table_A`.`PHASE`,
`table_B`.`Qty`,
`table_B`.`Calc` as calculated
FROM
`table_A`
Inner Join `table_B` ON `req_itemlist`.`ITEM` = `table_B`.`ItemID`

In my second statement I get my records that match in this case phase
401 in Table B and all my Table A records for phase 401.

SELECT
`table_A`.`ITEM`,
`table_A`.`DECSCRIPTION`,
`table_A`.`UM`,
`table_A`.`PHASE`,
`table_B`.`Qty`,
`table_B`.`Calc` as calculated
FROM
`table_A`

Left Outer Join `table_B` ON `req_itemlist`.`ITEM` = `table_B`.`ItemID`
Where
table_A.PHASE In ('401' )

Now I need to combine the Data of both recordsets. I need EVERYTHING in
Table B, but I also need All Table A records that match the phase
selection....

Can I write this one query or do I need to use a Temp table?

View Replies !   View Related
Count Related Records, But Show Records With NO Related Records Also
cl_items
========
it_id (pk)
it_ownerid
it_name

cl_offers
========
off_id (pk)
off_itid (fk) -> to it_id
off_whoid

My query needs to output ALL of the records in cl_items AND still show how many offers are on each item (from cl_offers)

I can't get what I want through the GROUP BY because I want to show the records in cl_items which DO NOT have any offers on them yet also.

Is there any way to do this with mysql only?

View Replies !   View Related
Delete Records That Have No Related Records In Other Table
How do I delete all records in a table that have no related records in another table? I tried this:

delete from t1 where t1.id=t2.id and count(t2.id)=0;

but it says "Unknown table 't2' in where clause". What's wrong?

View Replies !   View Related
How To Insert Multiple Rows With 1 Insert Query
I am having a form on the front end which has for example 3 rows each with 3 columns. The user enters data in all the 3 rows. When he hits the add button these should get in the database. What insert query would I write to add all of them together to the database? Do I need to use some procedure?

View Replies !   View Related
Delete Records Without Matching Records
I have a one to many relationship in my database. I would like to delete records in one table if there are no matching records in another table.

View Replies !   View Related
Can't Insert Image And Zip File But Can Insert Txt ,doc And Classes File
Mysql version is 5.1.
java program language

I put some data into the database .

following is table which I want to put datas.

+----------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| filedata | mediumblob | NO | | NULL | |
| filesize | int(11) | NO | | NULL | |
+----------+------------+------+-----+---------+----------------+

but ,when I insert image(jpg,gif ,etc) ,zip and rar file .The control show following message:

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 'cl|??u×??"a?!???>?TH°>?V?ìF^é?? ??? $?c^fSí k??é?t'”??5 <4?9B?ü?E6?—W?' at line 1 .

notice : I come from China ,so I set encoding is gbk .but I think this has nothing to do whith the error.

View Replies !   View Related
Records
I have a mysql database running on Mysql version 3.23.53 on a Red Hat
Linux 7.2. In the database there is a single table with over 150,000
records. Unfortunately, the performance of that table is very poor,
comparing to other tables in the same database.

View Replies !   View Related
10.000.000 Records
I've got some experience building PHP/MySQL websites, but the databases in these websites never contained more than a couple of thousand records. Now I've been asked to build a website with a database containing a table with roughly 10 million records.This amount of records gives me the creeps, to tell you the truth.
It's simple records, containing just 2 columns. The only thing a script would have to do is check wether a code is in the database or not.
Can I use standard PHP scripting methods and SQL queries, or does this amount of records demand a totally different approach? I can imagine an application getting very slow when it has to work with a huge recordset like this. What do I have to consider before I decide to build this site (or not)?

View Replies !   View Related
Certain Records
Code:

insert into users (username, password, email) select user , ID, email from selex.empleados_selex

but i want to copy only the records where its status is "working"

something like:

insert into users (username, password, email) select user , ID, email from selex.empleados_selex WHERE status =working`

View Replies !   View Related
Records 1 To 10, 10 To 20 Etc
im not sure how to do this or what to search for so any help would be great.
basically if i do a (select * from table) how do i get only the fiorst ten matches like records 1 to 10 then like on another page id have records 10 to 20. i thought i coudld use limit but when i do say

SELECT *
FROM `sale`
LIMIT 2 , 4

i get 4 results back instead of what i thought would have been results ows 2 to 4

View Replies !   View Related
Pf Records
Is it possible to specify the limit of records that can be entered in the table.

View Replies !   View Related
Get Records
I have one table (members) and a linked table (payments) and I trying to retrieve all the records in the members table that don't have a record in the payments table.The payments table is linked to the members table by memberId. Does anyone know how I would compare the two tables and bring back only the members that don't have a record in the payments table?

View Replies !   View Related
Records
I want to extract those values whose modificatio dates are few days older using the following sql
[SQL]
select status from note where mdate<=date_add(date('Y-m-d'),interval -2 day) and status='Selected' and id=$r[0];
[/SQL]
but the comparison 'mdate<=date_add(date('Y-m-d'),interval -2 day)' doing nothing. I have checked it in db. There is no error too. How to correct that?

View Replies !   View Related
40 Records
This is to gather a sample from the database.
I need to select 40 consecutive records every 1001st record.
So I would need records 1001-1040
and
records 2002-2041
and so on.
Anyone have a clue on how to write the query for this?

View Replies !   View Related
To Many Records
This query is getting me rows which dont = $cid can anyone tell me why? =x
Code:

"SELECT event.eventName, event.eventMonth, event.eventYear, exhibitor.standNum
FROM event, exhibitor
WHERE exhibitor.companyID = event.companyID AND exhibitor.companyID = '$cid'"

View Replies !   View Related
Records That Are Only From 3 Pm To 6 Pm
I have a field in my table called time which is a datetime field.

The format of the data is like these below:
2006-07-12 17:55:19
2006-07-11 16:31:34
......

I would like to get every records that are only from 3 pm to 6 pm. Is there any query where I can check for the hour of a datetime field?

View Replies !   View Related
Add Records (bug)
when a record is added, it adds 2 records instead of one. Code:

View Replies !   View Related
How To Get First And Last Records
i want to get the first record and last record using a single query?

is it possible?

View Replies !   View Related
Can't See Old Records
I really don't know much about mysql.
We have an hardware device performing bandwidht management which
we didn't even know it is using mysql until it was broken down.

After we solved the problem, we saw that the operationg system running in the device is linux (and old version) and the database is mysql.

The problem is that we can't see the old data eventhough when I
view the binary ISD file I can see the whole data including the olds.
But the management program doesn't show the old data. When I reenter new definitions from the management program, I can see that they are written into the ISD files. ISD files contains both old and new records but I can see the only new files.

Does that mean the index files are curropted?
If so, How can I recreate indexes or recover them?

View Replies !   View Related
Top 5 Records - ASP
I have an ASP application talking to a MySQL database. All works fine but:

1) I can't figure out how to select just the latest 5 records in a table.

2) SELECT LAST_INSERT_ID() doesn't work, it just returns 0.

3) I need to select the 'recordid' (held in the first field and is the PK) of the latest record.

View Replies !   View Related
No Records In DB
I connected to the DB like this:
Set rsP1000 = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT [G2P] FROM tblClients WHERE ClientID = '" & strID & "' AND GTime2 ='10:00a'"
rsP1000.Open strSQL, adoCon

I was wondering if the connection does not return any results, how do I display nothing. It keeps failing out because there is no record.

View Replies !   View Related
Searching For Records
eg search for records having same email address

select txtemail,count(txtemail) from `tbl_user` GROUP BY txtemail
having COUNT(txtemail)>1;

and it works, is that the best way?

View Replies !   View Related
Duplicating Records...
I have looked long n hard at the Insert Select as being the answer to my
need to create duplicate records. (Purpose is basically to allow someone to
create a duplicate of an existing email template then modify it). I have
tried all sorts of variations on:

INSERT INTO emaillist SELECT * FROM emaillist WHERE emailid = #url.emailid#
(inc trying IGNORE) but of course this throws an error over duplicate keys.

All I want to do is to take Record A, duplicate it and have a new key
assigned to it (the key is an autonumber field).

View Replies !   View Related
Last N Records By Some_id
Here is a problem I've encountered a few times lately:

Given

CREATE TABLE foo(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
some_id INT NOT NULL,
ts TIMESTAMP NOT NULL
);

find the last (ordered by ts) N id's for each some_id, with N > 1.

Is this possible in "pure" (i.e. without application code) MySQL 4.1.x?

View Replies !   View Related
Orphan Records
Given this setup:

inventory.itemID

item.itemID
item.description

I want a list of item descriptions which do NOT have an inventory
record. Any ideas?I did this before in MS Access as I recall by making
a query of things with inventory only then excluding those but I can't
even recall how to do that now. I'm working with php/mysql now and had
some luck generating aql with Access but not for this one.

View Replies !   View Related
Duplicate Records
mysql> select id, student_first_name, student_last_name, email,
application_date, modification_date, unique_key from student where id
in (7268, 862);
+------+--------------------+-------------------+----------------------------+---------------------+---------------------+------------------+
| id | student_first_name | student_last_name | email
| application_date | modification_date | unique_key |
+------+--------------------+-------------------+----------------------------+---------------------+---------------------+------------------+
| 862 | Phil | Powell | phil@blah.com |
2006-02-27 00:00:00 | 2006-02-27 00:00:00 | dF0WByrCP0vACftA |
| 7268 | Phil | Powell | phil@blah.com |
2006-02-27 00:00:00 | 2006-02-27 00:00:00 | dF0WByrCP0vACftA |
+------+--------------------+-------------------+----------------------------+---------------------+---------------------+------------------+


I accidentally created duplicate records upon attempting to migrate
data from one server to another. You will have 2, 3 or more records
with every single field identical except for the ID. Best way to know
they're dumps is by "application_date" along with "unique_key".

View Replies !   View Related
Sql To Get Most Recent Records
How would I write the query for mySQL to get all the records in a table that
were written in tha last 10 minutes?

I have a timestamp field (fldTime) that automatically inserts the curent
time when the record is inserted, but I'm unsure how to write a query that
would only get records from the last 10 miniutes.

View Replies !   View Related

Copyright 2005-08 www.BigResource.com, All rights reserved