Inserting New Data Within A Structured Sequence
I'm trying to organize rows in a specific sequence. However, I also want the capability to insert new rows within that sequence and not simply append them to the end of the dataset as autosequencing would have you do. How is this accomplished?
View Complete Forum Thread with Replies
Related Forum Messages:
Extract Data According To Preset Sequence... How?
wondering whether i can make this work... first, i will make an array like this: Quote: $category_id[]="10,6,9,8,3"; then i wanna extract the information( category name, category id, and sub category into array and arrange them in the preset sequence in category_id[] above. Quote: $query="select * from category order by $category_id[] "; $result="mysql_query($query) or die(mysql_error()); while ($row=mysql_fetch_assoc($result)) { echo $row['category_id']; echo $row['category_name']; echo $row['subcategory']; } the output i wish to get is like this: Quote: 1st result: category id: 10 category name= the name of category 10 sub category= sub 1 category 10 sub 2 category 10 sub 3 category 10 2nd result: category id: 6 category name= the name of category 6 sub category= sub 1 category 6 sub 2 category 6 sub 3 category 6 3rd result: category id: 9 category name= the name of category 9 sub category= sub 1 category 9 sub 2 category 9 sub 3 category 9 I'm confuse in the extraction info according to the preset sequence... can anyone please share some ideas? will this idea works?
View Replies !
Extract Information From Structured String
name: value; name1: value1; .... to write a query in such a way that I get back as result not the entire string but tuples(value, value1, value2, ..., valuen): SELECT name, name1, name2,...., namen FROM table where name contains the right value.
View Replies !
Inserting New Data
I have a form that has name, address, city, state, zip. All this goes into a single table. I want to add an additional table to put the cities into. I want to pull the cities from the city tables into a dynamic dropdown to choose the cities from.My problem is if I have a city already in the city table, I dont want to add it again and have duplicate citys in the dropdown. Anyone have a clues on how I would do this?
View Replies !
Inserting Data
Everytime I insert data into a table, The rows are rearranged so the primary key column is in alphabetical order. How does this happen? and how do I fix it?
View Replies !
Inserting Data Into Two Tables
if I want to insert data into two tables how do I do this? Is this right? I'm guessing not as it doesn't work What should I do? $query = "insert into requests (word,status) values ("$req","pending") AND insert into known_by (word,user_name) values ("$req","$user_name")";
View Replies !
Problem In Inserting Data
I have a table with 8 fields ,,in which one PK and two indices ,, now I want to insert a new data , and to avoid dublication I want to check the two indices together IF they are equal to the similar fields in the coming data , I want to remove the existed or update it completely (changing all the fields) , so I tried using INSERT.....ON DUBLICATE UPDATE .. it will check only the PK or one index then give you the chance to update one field ..(that what I understood about it). another way is , using REPLACE , but also it only checks the PK ... I dont want to check the PK.. it is only (AI) auto increment number HOw to do it saying like this : INSERT INTO mytable (A,B,C,D) VALUES (A1,B1,C1,D1) and IF the stored A == the coming A AND the stored C==the coming C THEN delete the existed or dont insert this row
View Replies !
Inserting Data Into Table
My task is to create a table which works as a "linker" of two other tables. In this linker table as foreign keys I am using keys from this two tables. I am inserting data into first table t1 in one loop in Perl script, then in a second loop I am inserting data into table t2 and immediately after into t3 which is a linker table between t1 and t2. I have no problems with id (primary key) from t2 , but while extracting keys from t1 there is message: Subquery returns more than 1 row after subquery: insert into t3 (t1id,t2id) values ((select id from t1 where name like 'x'),(select max(t2id) from t2)); simply because value '' are present in table t1 two times so it has two keys. How this problems can be solved? I tried to use: insert into t3 (t1id,t2id) values ((select id from t1 where name like 'x'=ANY(select id from t1 where name like 'x')),(select max(t2id) from t2)); however then there was a message:ERROR 1048 (23000): Column 'id' cannot be null because it is t1 primary key? Are there any ways of dealing with this problem?
View Replies !
Inserting Dynamic Data?
In the connectorJ example: stmt.executeUpdate( "INSERT INTO autoIncTutorial (dataField) " + "values ('Can I Get the Auto Increment Field?')", Statement.RETURN_GENERATED_KEYS); it works perfectly fine for static text. I can't seem to figure out a way to get it to accept dynamic data (from java beans etc) i.e. mybean.getA(), myBean.getDate for example: "values ('Can I Get the Auto Increment Field?'" + getA() ) gives me a compilation error. What's the proper syntax?
View Replies !
Inserting Data Into A Table
insert into enrolls (section_id,total) values(324,max(sub) +.1); how can I make it work so the value for the total of this entry is the max of the sub column from the same table + .1?
View Replies !
Inserting VB Data Into MySQL Using Ado
I am trying to insert some data into a MySQL db, with Visual Basic by using ADO. I can select data without a problem using adorecordset.open, to insert would I use adorecordset.addnew? if anybody has done this and has a sample script I would be very happy to check it out.
View Replies !
Trouble With Id + 1 When Inserting Data
I'm trying to find a good alternative for auto_increment, the reason is that I need to know what the next value of id will be before inserting data into the table and I haven't found a relyable way of doing that with auto_increment. My plan was to use a commend like: INSERT INTO temp (id, test) VALUES (MAX(id)+1, 'foo') But I am getting the error: ERROR 1111 (HY000): Invalid use of group function.
View Replies !
Problem Inserting Data
I'm having an issue inserting data into a MySQL database using PHP code which has worked before. Some of the fields in the form have been removed and so are not passing data across to the insert script and the insert has been altered to show this, apart from that everything is the same. Could anyone help me diagnose what is going on this code to not make it work, I've been looking for the last 2 hours and just cannot find the problem. Data entry page PHP <? if(isset($_GET[submit])){ $error='' if ($_GET['heightcm']=='') { $height=($_GET['heightinches']*2.54); } else { $height=$_GET['heightcm']; } if ($_GET['widthcm']=='') { $width=($_GET['widthinches']*2.54); } else { $width=$_GET['widthcm']; } if ($_GET['depthcm']=='') { $depth=($_GET['depthinches']*2.54); } else { $d
View Replies !
Inserting Unicode Data In Forms6i
i m using forms 6i with oracle 10g. i have set Nls_lang =American_America.UTF8. Now my problem is when i type some data i marathi Using a font converter engine directly into the text box on form i just get ?in the text box. when i type same data on notepad n then paste it in textbox it gets properly pasted and also get inserted in oracle.I m also able to retrive it back properly.So i think it is not the problem of my character set.Also i have set the font of textbox as Arial Unicode Ms. i m not getting where the problem is?
View Replies !
Inserting Data With A Partial List.
If I have an auto increment field in a table and I were to insert data into other rows that were in the table but left the auto incremented one out of the list of columns to insert would it cause an error?
View Replies !
Inserting Data Into Record With Condition?
i would like to insert data with "where" condition is this correct codes below? $query = "INSERT INTO photos (comments) VALUES ('$comment_tmp') where ID = '91'; I want to insert the $comment_tmp into comments only on ID = 91. Is this correct or wrong?
View Replies !
Inserting Data Into Mysql Database
i need to insert data from a txt file that is updating continously, select those info that i need by line, and after that adding them, i don't think that can be done in mysql; i've foud another program that i've made to read the file and select them, but now i don't know how to insert them in a data base, except php is there another program that can insert data into a mysql database?
View Replies !
Php Mysql Not Inserting Data, No Rerror Msg.
On development machine is a winXP and server for test is linux RHEL. I have a code that gets data from a form and insert into a table. -- $query_po_h = "INSERT INTO po_header (ponum, whs, extref, status, supplier, blkord, podate, remrk1, remrk2, remrk3) VALUES ('$ponum_t', '$whs', '$extref', 10, '$supplier', '$blkord', now(), '$remrk1', '$remrk2', '$remrk3') "; $rs_po_h = $db->Execute($query_po_h) or die("Error in query: $query_po_h. " . $db->ErrorMsg()); -- The problem here is it works on the development machine but doesn't work on the server. It is not generating error message at all. And only this particular query is not working. Other queries with the mysql database be it insert, update, delete or select works fine. Any idea why php-mysql will not work and still don't generate any error message?
View Replies !
Inserting Data Into Multiple Tables
I am just learning both MySQL and PHP, and have a question about a project I am working on. The first (and main) table for this project has the basic information about an refund request, including an autoincrement unique ID. Another table includes the products and uses the ID as a reference. The third table is the history of everything that happens to the request. For example, the information may be as follows. Credit table ID - autoincrement status - requested, needs authorization, processed, etc agent - who entered the request customer - person requesting the refund other customer info order table ID - reference to Credit table Item - item ID for amount requested quantity - number purchased price - price of each item (total information is calculated on above fields) history table ID - reference to credit table seq - id for each history log old status - the previous status new status- the status after the update to the record agent - agent making the change notes - a description of what was done. I have the PHP form that collects the data to be entered. My question is, since the first table is an autoincrement, what is the best way to insert a record into the Credit table, pull the ID that was just entered into the credit table and insert that ID into the order and history tables?
View Replies !
Inserting Time Data Into MYSQL
I'm trying to insert an assortment of data into a mysql database. Although I'm having problems when inserting fields with time information. Firstly, it's outputting it as HH:MM:SS and I need it to output as HH:MM. It's also defaulting as "00:00:00" even if I leave it blank. I've set it up as TIME and set the default as blank and NULL ...
View Replies !
Inserting Huge Amount Of Data In DB
I've got a script that scan .csv files and have to add data in a DB. I've try to save data into array and only insert data at the end in one shot, but I got memory problem. I would like to know the best way to add about 1 million of data in DB. Do I go with one query per data? Do I try to say cumulate like 100 data and then insert them and repeat this until it is done?
View Replies !
Inserting Large Amounts Of Data Into Mysql
I have a whole bunch of numbers and state, county, city, etc. data that i'm trying to load into a database for a demographics website. The data is all in excel currently so I could easily copy and paste it to a text file or another medium if necessary but I'm wondering what the quickest and most efficient way to get it all entered into mysql is.
View Replies !
Inserting 100 Rows Of Data Into An Existing Table
I want to import 100 rows of data from an Excel spreadsheet into an existing MySQL table. Both the spreadsheet table, and the MySQL table have the same exact format & headers. In MySQl Query Browser, I can locate only the Edit function, which seems to only allow me to type in the data line by line. Can I import the data in MySQL Query Browser, or do I need another product? And if I can import, how do I do this?
View Replies !
Inserting Data Into A Table From A Text File
I have a table in MySQL with the columns: "ID, JokeText, JokeCategory, JokeDate". I want to take a text file that is a long list of jokes, and load each joke into a new row of the table in the JokeText field. I have tried a bunch of different approaches, and just can't get it to work right. Can anyone enlighten me? If it helps, here is a sample from the jokes text file (yes, they are stupid :P) Q: What goes up and down but does not move? A: Stairs %% Q: Where should a 500 pound alien go? A: On a diet %% Q: What did one toilet say to the other? A: You look a bit flushed. %% Q: Why did the picture go to jail? A: Because it was framed. %% Q: What did one wall say to the other wall? A: I'll meet you at the corner. %%
View Replies !
Table Breaks After Inserting Data With MyISAM
One of my tables keeps getting broken after I add a bunch of data to it. I have reinstalled MySql and recreated the DB several times. In mysql 5 it says the table was marked broken and in mysql 4.1 it says "Got error 127 from storage engine". After I use repair table almost all of the data is gone, and only 10 from 1104 added rows remain, but it's always the same rows. It's the 10 rows where the value for volume is 0 (well it's 000 in the query). I am using the MyISAM DB-engine on my tables. I can fix this problem by changing the db engine to InnoDb, but I wonder why it doesn't work properly with MyISAM? the DDL code for the table is like this: CREATE TABLE `quotes` ( `ID` int(10) unsigned NOT NULL auto_increment, `security` mediumint(8) unsigned NOT NULL default '0', `open` float unsigned NOT NULL default '0', `high` float unsigned NOT NULL default '0', `low` float unsigned NOT NULL default '0', `close` float unsigned NOT NULL default '0', `volume` int(10) unsigned NOT NULL default '0', `splitfactor` float unsigned NOT NULL default '1', `date` date NOT NULL default '0000-00-00', PRIMARY KEY (`ID`), UNIQUE KEY `unique_security_date` (`security`,`date`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1 ; I uploaded the insert query I used here: http://users.skynet.be/ecare/insert_quotes.sql
View Replies !
SQL*plus Inserting New Row With Values = To Existing Rows Data
I am trying to insert a new employee into an empolyee table and get some of the values (namely phone no.) to be the same as what another employee currently has. This new employee is replacing the old employee, but i have to keep the old employee alive in the db as other data is reliant on its existance. I was wondering how do i insert the new employee asking the, VALUE ('etc', 'etc',) line, to assign a value to certain fields equal to the value contained in other employee rows.
View Replies !
Inserting Data From Text File Question
I have a sql table with about 9 fields of data in it.The first 3 are filled and the last 6 are currently blank. I have a tab delimited .txt file containing data for each of the 9 fields and want to import it in phpmyadmin to both overwrite the existing data in the 3 fields and fill out the other 6. However I only want to import the data where one of the existing filled-out fields "TournamentID" equals 10. But I'm unsure how to do this. Will this work?: SELECT * FROM `tbl_finish_pos` WHERE TournamentID=10 then check every row returned and select the Import tab in phymyadmin to insert the .txt file
View Replies !
Inserting Multi Table Data To Flat File
I have two tables; trying to get the data in to one row for the result set. Example: t1: iddescription 1apples 2oranges t2: idt1_idlabeldate 131added2008-01-23 141modified2008-01-23 132added2008-01-24 142modified2008-01-24 The result I would like to see is as follows: iddescriptiondate_addeddate_modified 1apples2008-01-232008-01-23 2oranges2008-01-242008-01-24 Looking forward to your solutions!
View Replies !
Disrupted Sequence
Another brainteaser: CREATE TABLE IF NOT EXISTS `test` ( `id` INT(11) unsigned NOT NULL auto_increment, `cid` VARCHAR(10) NOT NULL, `item` VARCHAR(10) NOT NULL, `val` INT(11) NOT NULL, `dt` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 In the above example table I need to find the first 5 highest values of val that break the sequential set of values. In other words: say I have values 49,48,45,44,43,40,39,37,36,34 of val in my table, with 49 being the highest value of val (need to sorted first, because values may randomly be dispersed in my table), then I want to get 47,46,42,41,38 as the query result.
View Replies !
Create A Sequence?
I am creating an application that will contain three tables that need to share the same sequence. Upon digging through the docs, I do not see how I could do this. Could someone give me some guidance into this? Also, As I read the docs, when I am creating tables, there is something about an InnoDB? Sorry to be confused, but I am not sure how to begin creating my database, nor tables without this knowledge.
View Replies !
Sequence Substitute
I have a problem about create sequence number which can be reset after MAXVALUE has been assigned. In the older version of mysql i can use "create sequence", but in the recent version i can't do that anymore. All i know in mysql ver 5 is "Auto_increment" which cannot be reset number without delete or truncate table.
View Replies !
CREATE SEQUENCE ?
Tracing some examples in a book from Apress, for some reason they go for Oracle in this book - not my cup of tea, especially not when I am sitting on a vista-terminal. Enough of my complaing. How do I create a sequence in mysql ? This is the example I am stuck with: CREATE SEQUENCE SEQ_ID_GEN INCREMENT BY 1 START WITH 100 MINVALUE 1 CACHE 50 ; How do I write that sentence in mysql ?
View Replies !
Sequence Generation
I was wondering if there was something close to CREATE SEQUENCE in MaxDB for standard MySQL. I'm thinking of just doing a table/stored procedure and calling it a day, but was wondering if MySQL had some other alternative.
View Replies !
What Collation Sequence?
I've just transferred a small PHP/MySQL application from a Firepages phpdev5 install to an XAMPP install, so I've got new versions of everything. I used phpMyAdmin to export and import the tables of the database. When recreating the database on my new install I selected the default collation (latin1_general_ci) but my application is now displaying ? in place of a number of characters so I guess I got it wrong. I can't see where in the old phpMyAdmin (2.3.0-rc3) to determine what collation the database uses.
View Replies !
Inserting Data Into Existing Records Of A Table From Other Table
how to insert data from one table to an existing records of another table.... In specific how can i insert data into a table....in such a way that this data should not be inserted as a new record,rather it should be inserted into the existing records(these records at first contains only two fields of data..the remaining fields contain default values) my question is that how to insert the data into these remaining fields from another table.(more specifically what is the insert statement used).
View Replies !
Identity, Sequence, Serial
Does MySQL offer capability for any of the following? - IDENTITY - SEQUENCE - SERIAL Or is AUTO_INCREMENT the catch-all for the functionality of all of the above? I ask because I'm looking into Java EJB3 which describes support for any of the above (as well as AUTO_INCREMENT, so I'm not out of luck completely).
View Replies !
Re-arrange Primary Key Sequence
i am facing a problem with my application when someone deletes a record and hence its key disappears breaking the sequence e.g 1 - entry 2 - entry (3 - deleted no mere here) 4 - entry 5 - entry When key is not there my AJAX application fails to run properly due to not finding next id. Is there any method to re-arrange primary key values to a proper sequence when one or more numbers are missing?so that i will write a query and whenever user deletes an item i will re-arrange the primary key sequence automatically
View Replies !
Selcting Date Sequence
I am trying to return a set or rows that represent all of the days between two dates. For example, I want to select all the days between December 25th, 2005 and January 5th of 2006, and i am looking for it to return (shown here in CSV) 2005,12,25 2005,12,26 2005,12,27 2005,12,28 2005,12,29 2005,12,30 2005,12,31 2006,01,01 2006,01,02 2006,01,03 2006,01,04 2006,01,05 So, for any date, i want to select all the days in between. Any ideas?
View Replies !
Order By An (out Of Sequence) Set Of Numbers
I'm having a problem as follows: here is a an example table (tbl_test): id | value ---------------- 1 | hello 2 | hi 1 | bye 4 | cya where the value field is variable. and i want to select them so they are listed as follows: id | value ---------------- 2 | hi 1 | bye 1 | hello 4 | cya is it possible to order by and array - something like: SELECT * FROM tbl_test WHERE 1 ORDER BY id (2,1,4)
View Replies !
How To Create A Sequence In MySQL
I am not able to create a sequence in MYSQL 5.0 Want help on creating the same. Basically, what I am looking for is, that I should get a number greater that the last one on every call to this sequence. In Oracle, one can simply write something like:- CREATE SEQUENCE seq_ordermaster increment by 1 start with 1 maxvalue 999999minvalue 1 nocache Nocycle; And while calling, one can use it by selecting seq_ordermaster.nextval from DUAL Considering the fact that there is no DUAL table in MySQL, how can One write such a sequence and also, how one can get the next value on each select statement?
View Replies !
Mysql Execution Sequence
I need to retrieve the last value from a column in a mysql table, perform some actions on it, then add 1 to the original value and store a new entry. I am worried that if multiple users access the database at the same time I will end up with duplicated 'new values'. Does mysql complete execution of a script before it allows access to another user or do I need to 'lock' the table in some way while the script executes?
View Replies !
Find The Number Of A Row In A Sequence
MySQL Code: SELECT * FROM comments WHERE id=12345 ORDER BY rating Is there a way to determine the position that this rows appears in the sequence? Eg, so I can print out: "This site is rated position x out of y"
View Replies !
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 !
|