Creating Child Records For Each Parent Record
I want to iterate through a parent table and then create a child record for each.
Something like this (pseudocode):
select * from parent;
//Then for each parent I want to create a child and insert the parent vlaue
insert into child(parentId, someField) values(parent.id, "XYZ");
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Selecting All Records In A Parent/child Tree Structure
I have a tree menu and I am filtering it so that it shows only nodes in the tree that have products against them. I have two tables: 1. Tree table Name: 'shopCategory' Fields: cat_pk category_text parent_pk url 2. shop items Name: 'shopItems' many fields but key field of TDCategoryID links to cat_pk in the shopCategory table I have got as far as: SELECT * from shopCategory WHERE cat_pk in (Select TDCategoryID from shopItems); This gives me all the nodes that have items against it: +--------+--------------------------+-----------+------------------------------- | cat_pk | category_text | parent_pk | url +--------+--------------------------+-----------+------------------------------- | 89 | Food and drink | 1 | ***** | 93 | Vitamins and supplements | 89 | ***** | 94 | Wine | 89 | ***** | 100 | Other wine | 94 | ***** | 121 | Home and garden | 1 | ***** +--------+--------------------------+-----------+------------------------------- What I need to do now is follow the parent/child relationship and return all the records to the recordset until parent_pk is '0' i.e. the top of the tree. THe problem is the length of the tree varies so it may be folder|items or folder|folder|items is this possible?
View Replies !
View Related
SQL On Parent And Child Filter
I have the following database tables: Treemenu idparent_idTitle 1Folder 1 2Folder 2 31Product Type 1 41Product Type 2 52Product Type 3 62Product Type 4 Where the record has a parent id (and no child) it is a product type with products linked to it Where a record has no parent it is a higher level folder where a record has both a parent and a child it is a mid level folder Products idtreemenu_fktitle *many other fields* 13Product 1etc 23Product 2etc 33Product 3etc 44Product 4etc 54Product 5etc therefore in this example The product types 5 and 6 are not used meaning that nothing under folder 2 is user
View Replies !
View Related
Joining Parent With Child Table
I seem to always want to do this type of join, but I can never find how to do this.I am trying to join two tables. The parent table will always have one row of data and the child may have 0 to 45 rows of data. I am trying to join the tables in an outer join, so if 0 rows in child it is not affected. But I only want one row returned of the child. How do I do this in mySQL? I have tried LIMIT, but this is not quite what I wanted.
View Replies !
View Related
Parent-child Sophisticated SQL Query?
I have a table (relation) in my database: --------------- | parent | child | --------------- | 1 | 2 | | 1 | 3 | | 2 | 4 | | 2 | 5 | | 3 | 6 | | 5 | 7 | | 5 | 8 | --------------- This table reflect the relation between two persons, the first column is the parent, the second column is the child, the a child could be a parent to other childs. Is it possible to construct a SQL query to start from a parent and get all his siblings, I was able to get the direct children of a parent but not all his siblings, for example to get the direct children of parent 1 I used the following query: select child from relation where parent=1.
View Replies !
View Related
Parent And Child Category Query
I have a simple table that has category_id and parent_category_id I want it to loop through and get all the categories and and their child categories - cant seem to get it. I read this article and it hasnt helped much http://sqllessons.com/categories.html category_id cat_name parent_category_id network_id The query that wont work is SELECT parent.category_id, parent.cat_name as parentCat_name, parent.parent_category_id, child.cat_name as ChildName from faq_category parent LEFT JOIN faq_category child ON parent.category_id = child.parent_category_id where parent.network_id = '$var'
View Replies !
View Related
Count Child/parent In Same Table
Is it possible to do a count in the same table. I will explain it better. I have a categorie table catID catParentID catName id1: parentID:0 >> europe id2: parentID:0 >> asia id3: parentID:1 >> france id4: parentID:1 >> germany id5: parentID:2 >> china id6: parentID:3 >> paris id7: parentID:3 >> bordeaux id8: parentID:3 >> nice id9: parentID:4 >> berlin id10: parentID:4 >> munich id11: parentID:5 >> bejing So let's say I want a query which displays the amount of cities in the countries: germany: 2 france: 3 china: 1 Or the total amount of cities in a part of the world asia: 1 europe: 5 Can it be done within one query?
View Replies !
View Related
How To Update Parent And Child Tables At The Same Time
I'm using phpMyAdmin to learn how to do MySQL queries. Once I figure them out I put them into my PHP code, which I'm also learning. I can do a SELECT query with a LEFT JOIN and get results. My next step is to figure out how to update 2 related tables at the same time. I have tblBudget and tblBudgetDetail. tblBudget has tblBudgetID and tblBudgetDetail has tblBudgetDetailID and BudgetID (which should hold the same value as tblBudgetID in the related record tblBudget) Code: tblBudget tblBudgetDetail tblBudgetID--| tblBudgetDetailID |---BudgetID crude, but perhaps you get the idea. The join is one to many. One tblBudget to many tblBudgetDetail. So is it possible to update both tables with one query? I guess the query would have to populate the field BudgetID in tblBudgetDetail with the same value that is in tblBudgetID in tblBudget. Does MySQL do that automatically?
View Replies !
View Related
Some Weird Parent/child Table Combo
I have two tables, a parent table and a child table. How would I structure a query, which returns records from the parent table if all of the items in a list are in it's children records? If, however, not every single item in the list is the name of a parent's child, it isn't returned. for example, a list example could be: childname1 childname5 childname7 and the parent/child structure could be (using parent.name and child.name): parentname1 childname1 childname2 parentname2 childname1 childname2 childname5 childname6 childname7 parentname3 childname1 childname5 childname7 parentname4 childname1 childname7 I only want: parentname2 and parentname 3 to be returned, because all of the items in the list are child records in the parent. if it doesn't make sense - just tell me and i'll try and refine it.
View Replies !
View Related
Ideal Way To Preserve All The Parent Table Entries In A Join With Many Child Tables
The problem is: How do I join a huge parent table with many child tables (more than 5 child tables) preserving all of the parent table entries. Lets say there is the parent table parentTable and three child tables childTable1, childTable2, childTable3. In order to get the data after joining these tables the query that I have been using was: select parent.field1, parent.field2, parent.field3, child1.field4, child1.field5, child2.field6, child3.field7 from ParentTable parent, childTable1 child1, childTable1 child2, childTable3 child3 where parent.fielda = child1.fieldb and parent.fieldc = child.fieldd and parent.fielde = child.fieldf. Although the tables are huge (more than 100,000 entries), this query is very fast, however those parent table entries which do not have child entries are lost. I know that I can left join a parent table with a child table and then with the next child table and then with the next child table and continue. Isn't there a simple solution for this commonly happening problem?
View Replies !
View Related
Can I Store The Sum Of Row's Child Rows' Field In A Parent Field?
Sorry if this has been posted before; I am not sure what to search for. I have a table of users, `users`. In the table `users` there is a row which stores clicks, `users`.`clicks`. Each user has it's own referrer, `users`.`referrer_id` which refrences the referring user's id. In the referring user's row, I would like a field to store referral clicks, `users`.`referral_clicks`. I would like `users`.`referral_clicks` to be updated each time that a child user's `users`.`clicks` field is changed. Is this easily possible in MySQL?
View Replies !
View Related
Delete A Record With Parent ID
Given a table like table config { cfgId; name; parentID; } I would like to delete all records where the parentID is set to some number. I tried the following: mysql_query("DELETE FROM config WHERE parentID=3"); The command is accepted but no records are deleted. I know the table has entries with that parentID number. Is this not the correct way to do this? If it is, how do I troubleshoot this to find out why it is not working?
View Replies !
View Related
Return One Child Record
I have a table `entity`, which holds info about organisations (nurseries, botanical gardens etc). A child table `file` stores links to images for these organisations. A field `sort_order` lets me sort them in order of importance (1 is highest). If the field is null it is assigned 99, eg: if(sort_order is null,99,sort_order) as sort_order On a search results page, I would like to return only one image per organisation, but I'm struggling to create a query or view that can do this.
View Replies !
View Related
1 Record To Multiple Records
I'm looking for an efficient way of doing the following... table1 - groupName, firstGuy, secondGuy, thirdGuy,... sample - 'Red', 2, 6, 3,..... table2 - guyId, firstName, lastName sample - 2, 'Jim', 'Smith' ; 3, 'Bill', 'Adams' ; 6, 'Tim', 'Jones' If I queried groupName = 'Red', how do I get the result to be the names from table2. Subqueries?result to contain: red, Jim Smith, Bill Adams, Tim Jones I hope this is clear.
View Replies !
View Related
Check If A Record Exists In The Last 30 Records
I want to check if a record exists in the last 30 records that were added. For example, i have a table wich contains about 34000 records by now. But i want to check if the songID is in the last 30 records. Now i select the last 30 records and put them in an array, and let php check if this songID is in the array. But it must be much easier if mysql this does!
View Replies !
View Related
Storing Many Records Associated To Single Record
Let's say that you have a table of car models and each model is associated to a make in another table through a foreign key. Now, in another table you need to store all of the models that the customer has selected. Is it correct to store them in a table like this (periods used for spacing): user_id, model_id ...1........1 ...1........2 ...1........4 ...2........2 ...2........23 ...3........9 etc. or is there a way to serialize this data that's easily searchable like this? user_id, models ...1.....1,2,4 ...2......2,23 ...3.......9 etc. Which is considered the best practice? I need to be able to quickly search for all people who have selected model_id "2" or model_id "23".
View Replies !
View Related
Finding Records That Are *similar* To Your Record
I want to enable users to create groups in my website. However; i also want to check that lots of users dont go and create lots of similar groups because they are unaware that other groups exist. So: i need to be able to find groups in my database which have names (if any) which are similar to the one that the user has entered in. Is there any existing MySQL function for doing this? One thing which i have found is the liebenstein distance, but it appears that you have to install that function as a user function or something...which seems a little beyond me right now. Is there perhaps another way of finding the similarity between two strings?
View Replies !
View Related
Creating A Query That Will Only Return Records With Matching Counterparts
I'm using the table below as an example. I want to create a MySQL query that will return only records that have matching counter-parts where 'col1' = 'ABC'. Notice the 'ABC / GHI' record does not have a counter-matching 'GHI / ABC' record. This record should not be returned because there is no matching counter-part. With this table, the 'ABC / GHI' record should be the only one returned in the query. How can I create a query that will do this? id | col1 | col2 -------------------- 1 | ABC | DEF 2 | DEF | ABC 3 | ABC | GHI 4 | DEF | GHI 5 | GHI | DEF
View Replies !
View Related
Get Previous And Next Records Relative To An Index Record
Suppose I have a table "product" with fields id,name,price. I want to get a resultset of previous and current and next record when the resultset is sorted by id and id=10. The table data is shown in the following: id Name Price 1 : : 5 : :<--------------previous record 10 : :<--------------id=10 12 : :<--------------next record 14 : : How do I write the sql statement if I do not know 5 and 12 are the previous and next id respectively?
View Replies !
View Related
Selecting Values For This Record Based On Other Records
Is it possible in a select to reference the contents of a column in a different record to the one currently being assessed? Kind of like :- Select id,prev_id,title,flag FROM my_table WHERE flag != "S" AND flag(prev_id)="S"; What I'd like it to do is select records which have flag set "S", but the record referred to in prev_id do not have flag set "S". If it matter, I'm stuck on 4.0.
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
Query To Retrieve 5 Records Immediately Before And After A Particular Record In Sorted Manner
Just consider a simple table with one integer column (however numbers are not inserted in sorted manner and some of them may be missing). Given a particular record, say 32, I would like to retrieve 5 records immediately before and after this record in ascending manner of sort. So, in this case I should get 25, 27, 28, 30, 31, 32, 33, 34, 37, 38, 39 (I did not have 26, 29 and 35 in the table) Why do I go about writing such query?
View Replies !
View Related
How To Cascade Delete Related Records Without Deleting The Main Record?
Let's say I have the following database tables: CREATE TABLE user ( id INT UNSIGNED NOT NULL PRIMARY KEY, username VARCHAR(20) NOT NULL, ) ENGINE = INNODB; CREATE TABLE user_email ( user_id INT UNSIGNED NOT NULL PRIMARY KEY, email VARCHAR(100) NOT NULL, FOREIGN KEY (user_id) REFERENCES user(id) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = INNODB; CREATE TABLE user_phone ( user_id INT UNSIGNED NOT NULL PRIMARY KEY, phone VARCHAR(100) NOT NULL, FOREIGN KEY (user_id) REFERENCES user(id) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = INNODB; What I want to do is delete all records in the 'user_email' and 'user_phone' tables without deleting the record in the user table. I have a database without nearly 20 tables with one-to-one and one-to-many relationships with the user record and I need a way to cascade delete records in relationship tables.
View Replies !
View Related
Finding All Records In One Table That Don't Have A Corresponding Record In Another Table
I have photo information stored in a table called pictures. One column is keyword. Visitors to my site can search for photos by keyword. I record search terms in another table called searches. Each search term is recorded, meaning there are duplicate search rows. This allows me to see easily the popularity of a search term. Step 1. What query can I run to find all search terms that return no matching picture in the picture table. I tried the following, but no luck:Quote:select term from searches left join pictures on term like keyword where picture_id is NULL
View Replies !
View Related
Finding The Parent Id
I am new to these boards and to SQL. My question is I am trying to find the parent id of a child and have its output What I have so far: Database: id#name#subcatof 0#Home#0 1#About Me#0 4#Sub Category#1 PHP <p><? echo l('subcategory'); ?>: <? $query = "SELECT * FROM " .s('prefix'). "categories WHERE subcatof = id"; $result = $db->query($query); while ($r = $result->fetch_array()) { echo $r['name']; } ?> It outputs: Sub Category of: Home It is not selecting About Me, how can I make it select ABout Me?
View Replies !
View Related
Order By Parent
I have a MySQL table id | name | parent 1 item1 2 item2 item1 3 item3 item1 4 item4 item1 5 item5 item2 6 item6 item2 I want the items to be ordered by their parent e.g. item1 item2 item5 item6 item3 item4 Is this possible at query level?
View Replies !
View Related
Parent Subcategory Query
i am storing category & it's subcategory up to n' th level using following db schema. catid parentid 1 o //parent 2 1 // sub cat under 1 3 0 //parent is it possible for me to find out count of how many products exists in category(including its subcategories products) also listing oout subcategories in one query?
View Replies !
View Related
Sorting A Parent Table
What is the best way to order the records in a table according to the number of child records they each have in a given child table? ex: Table Parent: id: name: 0 Michael 1 John 2 Alex And the child table has a foreign_key that references the Parent table Table Child: parent_id: name: 1 Ann 1 Sue 1 Jan 0 Sara 2 Tess 0 Jill 1 Alli I want to sort the Parent table records in the order of how many child records they have (John - 4, Michael - 2, Alex -1)
View Replies !
View Related
Catagory/Subcatagory (With No Parent)
I am atempting to mod a current store front that a customer of mine uses. The database doesn't seem very well structured however they have alot of data already stored in it (witch i do not mind adding extra fields to the current Database) ok now on to the question: The table is designed as such ID (Primary Key) - Text Name - Text Category - Text SubCategory - Text Description - Memo OnWeb - Text Ok so when someone does a search on the site (by catagory/keyword) it executes this query: SELECT * FROM Products WHERE (OnWeb = 'Yes') AND (Category = '#Cat#') AND SubCategory LIKE '#SubCat#' ORDER BY SubCategory Now I can't see a way to list the data in the following way without a parent ID (witch there is none) Catagory -Subcatagory -Item1 -Item2 -Subcategory -Item1 -Item2 -Item3 And when someone does a master search for all to add Catagory into the drop down list Catagory -Subcatagory -Item1 -Item2 -Subcategory -Item1 -Item2 -Item3 Catagory2 -Subcatagory -Item1 -Item2 -Item3 -Subcategory -Item1 -Item2 Sorry for the long post just trying to be specific Also if it is relevent I am useing an access database and the programing language is coldfusion (I know this is a MySQL forum however I think my error is in the SQL statment and no one in coldfusion knows the fix)
View Replies !
View Related
Finding Child Tables?
Is there an easy way to find child tables for any given table in MySQL 4.1? Right now, I'm running SHOW CREATE TABLE `$table` for all tables, and then seeing if they have the table I'm looking for any foreign key relationship. There has got to be a better way, right?
View Replies !
View Related
Child Tables MySQL 4.1
Is there a way to look for all the child tables of a table in MySQL 4.1? I know for the latest version of MySQL you can use information_schema.table_constraints to look the same. Is there something similar there for MySQL 4.1? Right now, I'm running SHOW CREATE TABLE `$table` for all tables, and then seeing if they have the table I'm looking for any foreign key relationship. This dosnt seem to be the most effective way of doing it.
View Replies !
View Related
Master Child Reporting
Need to create a query that will pull a status field from a child table based on two seperate fields. One is date and the other is time. Can not use datetime field due to restictions in other legacy application. Want to select single related record with the highest date and time.
View Replies !
View Related
How To Get The Last Auto Increment Key Value For Child Tables
How to find out the last insert primary key value when a field is auto incremented. Select the maximum value from the table is not an option because users can add rows very quickly. First I have to insert the values for table t_id. The value of id is needed to insert for table t_idreply. How to get the primary key value for t_id ? CREATE TABLE `t_id` ( `id` bigint(20) NOT NULL auto_increment, `subject` varchar(128) NOT NULL default '', PRIMARY KEY (`id`), ) TYPE=MyISAM AUTO_INCREMENT=1; CREATE TABLE `t_idreply` ( `id` int(11) NOT NULL default '0', `volgnr` int(11) NOT NULL auto_increment, `reply` longtext, PRIMARY KEY (`id`,`volgnr`) ) TYPE=MyISAM AUTO_INCREMENT=1 ;
View Replies !
View Related
So Many Child Process Of Mysqld (version 4.0.21)
I upgread mysql 3.23.56 to 4.0.21, succesfully upgraded. But, I observed abnormal behaviour of mysql (or may be i dont know). Thing is, in mysql 3.23.56 when I start service, only one procses exist [ check thru command ps -A | grep mysql* ] but when I upgraded to mysql (4.0.21). Above command shows me 25+ mysqld child process. Is this is correct or any problem. Logs [/var/log/mysql.log] shows me successful start/stop.
View Replies !
View Related
InnoDB Autodeletion ONLY When ALL Parent Rows With ID=x Are Deleted, Possible
I have a simple, but very general problem with MySQL using InnoDB tables. I am sure you experienced folks can give me a solution... Using foreign keys I want to delete a row in the table T_Child with WHERE T_Child.Parent_ID=x when ALL ROWS in the Parent table with ID=x are deleted. (This behaviour is very useful when Parent table is a list where T_Parent.ID is the ID column of the list and hence, x can occur multiple times in this column.) As it is now, as soon as ONE row with ID=x in the Parent table is deleted, all rows in the Child table WHERE Parent_ID=x are also deleted.
View Replies !
View Related
Grouping Entries By Entry Date And Parent ID
With tables: 'Category' comprised of (and containing e.g.) ---------------------------------- categoryId | title | description ---------------------------------- 1 | Animals | Different kinds of animals. 2 | Cars | I love cars. and 'Subject' comprised of (and containing e.g.) ----------------------------------------------- subjectId | categoryId | title | description ----------------------------------------------- 1 | 1 | Welfare | Something about animal welfare. 2 | 2 | Engine | Something about the engines of cars. and 'Issue' comprised of (and containing e.g.) ------------------------------------------------------------------- issueId | subjectId | parentId | status | entryDate | text ------------------------------------------------------------------- 1 | 1 | 1 | Not done | 2007-01-12 10:00 | Feed my dog. 2 | 1 | 1 | Done | 2007-01-12 10:05 | Feed my dog Alex. 3 | 1 | 3 | Done | 2007-01-13 11:00 | Feed my cat. 4 | 2 | 4 | Done | 2007-01-14 12:00 | Get new engine. I would like to do a SELECT which will join these three tables, and give me the following result. ------------------------------------------------------------- catTitle | subjTitle | issueText | status | entryDate ------------------------------------------------------------- Animals | Welfare | Feed my dog Alex. | Done | 2007-01-12 10:05 Animals | Welfare | Feed my cat. | Done | 2007-01-13 11:00 Cars | Engine | Get new engine. | Done | 2007-01-14 12:00 Note how the newest entry of issues with the same parentId overwrites the ealier entries with the same parentId. This is because I would like to keep some log of what has happened in the database, when I for example updates the dog-feeding situation from "not done" to "done". What does my SELECT look like to accomplish this? NB: Copy/paste this into a word editor and use a monospace font for optimal rendition.
View Replies !
View Related
Foreign Key :: 1451 - Cannot Delete Or Update A Parent Row
I have a customer table and a products table. The clientID is a foreign key inside the products table. If i edit the clientId inside the product table i get: 1451 - cannot delete or update a parent row; a foreign key constraint fails ('database01/customers', CONSTRAINT 'client_ibfk_1 'FOREIGN KEY('clientId') REFERENCES 'Products' ('clientId')) any ideas ? :| From the customers table : CONSTRAINT `client_ibfk_1` FOREIGN KEY (`clientId`) REFERENCES 'Products`
View Replies !
View Related
Foreign Keys (Multiple Parents For Child)
I have three tables (Site, Client and SubClient). All of these have a _msgSetId field that references to a row in a table called MsgSet. Each table has a one to one relationship with MsgSet. Site, Client and Subclient don't share data with each other via MsgSet. They just all happen to all need to store the same stuff, so I separated it out in to a separate table. What I want to do is be able to delete a row from Site, Client or Subclient and have the row in MsgSet belonging to it also be deleted at the same time via a cascade. Kinda like this:
View Replies !
View Related
ERROR 1217: Cannot Delete A Parent Row: A Foreign Key Constraint
I'm using: - Red Hat 9 - MySQL 3.23.56 create table t1( id integer not null, primary key(id)) type = INNODB; create table t2( id integer not null, code char(5) not null, primary key(id,code)) type = INNODB; create index t2_id on t2(id); alter table t2 add constraint foreign key (id) references t1 (id) ON UPDATE CASCADE; insert into t1(id) values(1); insert into t2(id,code) values(1,'a'); insert into t2(id,code) values(1,'b'); update t1 set id=2 where id=1; I get the following error message: "ERROR 1217: Cannot delete a parent row: a foreign key constraint fails" What am I doing wrong?
View Replies !
View Related
Distinct List Of Parents With A Child Count Result
Parent (id, name) Child (id, parent_id, session_name) I'm trying to write a query that will have one output row per Parent. Each row will show: parent.id, parent.name, count of children for that parent AS children_count Some parents have no children. Those rows could return null or 0 for the children_count field. I know multiple methods external to SQL to solve the overall problem such as returning the join and counting where child.ids (for the same parent) is not null. ==>> but is there a way to do it in one SQL query that returns just the info I need?
View Replies !
View Related
Error 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails.
I am creating a contacts database using family information. My tables in question look like this: create table Household ( HouseholdID int(4) not null, LastName varchar(100), constraint pk_HouseholdID primary key (HouseholdID) ); create table Personal ( PersonalID int (4)not null, HouseholdID int (4) not null, AddressID int (4) not null, FirstName varchar (20), LastName varchar (60), constraint pk_PersonalID primary key (personalID) ); create table ContactInfo ( AddressID int (4) not null, PersonalID int (4) not null, lastName varchar(50) not null, mailingAddress varchar(60), City varchar(25), state varchar (20), ZipCode varchar(5), PhoneNumber int (10), EmailAddress varchar (60), constraint pk_AddressID primary key (AddressID) ); ** I have others, but these are the ones involoved in the issue** Here is what I am trying to update with: insert Personal values (0100,0001, 1000, 'Gram & Gram', 'Holbrook'); THis is my error: [mobile3] ERROR 1452: Cannot add or update a child row: a foreign key constraint fails (`directory/personal`, CONSTRAINT `fk_AddressID` FOREIGN KEY (`AddressID`) REFERENCES `contactinfo` (`AddressID`))
View Replies !
View Related
Automatically Record Date Of Record Entry
I have my database table set up and I have an HTML form that is PHP driven that will add the information entered into the form into to my database table. I have a local buy-sell-trade Website. The way it has worked is that people fill out a form and the results emailed to me. I then take the information and enter it into a Web page. I only want the ads to be displayed for 30 days. I keep the ad for a total of 6 weeks (displays for 30 days and sits in limbo for 2 weeks afterwords) and if not renewed within that 2 week limbo period - I delete it. Entering all the ads and keeping up with the dates manually has become a burden. I've only recently began looking into databases. My hosting company provides me with phpmyadmin and mysql 5.0. I'm new to all of this but I have managed to set up a database table and a HTML form that is PHP driven that allows ads to be automatically added to the database table. There is a lot I need to do to make this ideal, but one step at a time. First, I need to know the date (March 02, 2006) the ad was created or added to the database table. I know that I need to add some piece of code to my php form to record this information, but what code and where do I put it? I know I will need to create an extra field in my database table to house the date - I can handle this. I've read the date and time information here http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html but there's a lot there and I don't know which is right for my needs. Plus, it doesn't tell me how or where to insert it into my php form (or does it?).
View Replies !
View Related
Getting Record Before Or After The Record That Meets The Criteria
In a query I want to get all the results and then order those results by last name, but then I want to filter those results down to only the record that comes before or after the record that has 'empno' = '1259'. I want to get all the results already ordered and then filter them down to one record either before or after (depending on what is needed) the record where 'empno' = '1259'.
View Replies !
View Related
How To Record The Current Record In A Table?
I'm looking at convert file formats to mysql. The original file format used an "ENTRY" conception to record the current record. But I cannot find a solution to emulate "ENTRY" conception in MySQL. After searching MySQL's tutorials, the AUTO-INCREMENT fields would only use "mysql_insert_id()" to obtain its value. But this value cannot identify the current record, Right? This value are only last record after inserting? Who can help me to find a better solution to emulate implementing what the "ENTRY" does. In other words, How to obtain the auto-increment value contains AUTO-INCREMENT columns in a record which generated by SELECT statement.
View Replies !
View Related
Record Creates Record
I have a table that holds inventory information...primary key'd with an asset#. I have another table that I hold certain information in that I don't want in the main inventory table. I would like the second table to key itself and automatically enter a record when a device is entered. For example, I enter a scanner in my main table, but I want the DB to then also enter that assetNumber into the second table for me.
View Replies !
View Related
|