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.





Updating Rows In Table B Based On Related Field In Table A


Ver 4.1.8-standard for apple-darwin7.6.0 on powerpc (Official MySQL-standard binary)

I am trying to do some data migration based. I have several tables that contain our legacy pkey field and I want to update the tables with new ID's.
I need to do this several times and have tried it several ways to no avail.

Table A
---------
companyID int(10) pKey
legacyID int(10) old legacy pkey

Table B
---------
bAID int(10) pkey
companyID int(10)
legacyID int(10)

Table A has values for both companyID (unique key) and legacyID.
Table B has values for bAID (unique key) and legacyID but companyID is empty.

I need to update tableB.companyID with tableA.companyID based on tableb.cSerialID to tablea.cSerialID relationship.

I need a query that will update ALL rows.




View Complete Forum Thread with Replies

Related Forum Messages:
Updating Table Based Upon Matching Field In Second Table
I have a database of books that was originally created as a flat file.
Each record has a number of fields, including the authors name. I'm
trying to convert the database to something a little more efficient.
I've created a new table (called Authors) of unique authors names and
assigned each one a unique ID. I've added a new field in the original
table (called Books) for the author's ID. Now, I need to update the
original table with the author ID from the Author's table.

Something like this:

UPDATE Books SET AuthorID = Authors.AuthorID WHERE AuthorName =
Authors.AuthorName

This obviously doesn't work. Any assistance on how to forumulate this
query (or, if I'm headed down the wrong path, the correct way to do this
operation) greatly appreciated.

View Replies !
Two Table Query: Grab Rows From One Table Even If No Related Row In Other Table
PHP

$gettray = mysql_query("SELECT trailers.title,
trailers.link,
trailers.movie,
movie.title AS mtitle
FROM trailers,movie
WHERE trailers.movie=movie.word
ORDER BY trailerid
DESC LIMIT 6",$connm);

It works great, but there is one problem. It will not grab any rows from the 'trailers' table if a corresponding movie row does not exist in the 'movies' table.

I want it to pull ALL rows from the 'trailers' table, even if the corresponding row in the 'movies' table does not exist yet.

If the row does not exist in 'movies', the program than uses the entire trailer title like so


PHP

if($ttray['mtitle']) {
  $newttitle = explode("-",$ttray['title']);
$newttitle = array_reverse($newttitle);
$ttitle = $newttitle[0];
$ttitle = $ttray['mtitle'] ."- ". $ttitle;
} else {
$ttitle = $ttray['title'];
}



Thanks
Ryan

View Replies !
Updating A Table Based On The Value In Another Table In Ver 3.23.54-Max
I am trying to update fields in table SOLAR_SYSTEM based on the values in RESEARCH_LEVEL table

This is a SQL that I am trying to use

UPDATE SOLAR_SYSTEM JOIN RESEARCH_LEVEL ON SOLAR_SYSTEM.USER_ID=RESEARCH_LEVEL.USER_ID SET
SOLAR_SYSTEM.CASH_METAL=SOLAR_SYSTEM.CASH_METAL+1000,
SOLAR_SYSTEM.CASH_CRISTAL=SOLAR_SYSTEM.CASH_CRISTAL+1000,
SOLAR_SYSTEM.CASH_ENERGY=SOLAR_SYSTEM.CASH_ENERGY+1000
WHERE RESEARCH_LEVEL.TYPE='M' AND RESEARCH_LEVEL.LEVEL=1;

I got error

"ERROR 1064: You have an error in your SQL syntax near 'JOIN RESEARCH_LEVEL ON SO
LAR_SYSTEM.USER_ID=RESEARCH_LEVEL.USER_ID SET
SOLAR_SY' at line 1"

I don't know what is wrong. Can I do such an update in Ver 3.23.54-Max in the first place ? IF yes, then what's wrong with my statement?

View Replies !
How To Delete From 1 Table Some Rows Based On Match Results In 2nd Table?
How to delete from TABLE-1 all rows with indexes "i" that match to index j=2 from TABLE-2?

TABLE 1:
+---+------+
| i | name |
+---+------+
| 1 | item1 |
| 1 | item2 |
| 7 | item3 | <-- delete all rows with i=5,6,7
| 6 | item4 | <-- delete
| 5 | item5 | <-- delete
| 5 | item6 | <-- delete
| 7 | item7 | <-- delete
+---+------+

TABLE 2:
+---+---+------+
| j | i | name |
+---+---+------+
| 1 | 1 | item1 |
| 1 | 3 | item2 |
| 1 | 2 | item3 |
| 2 | 5 | item4 | <---- j=2 => i=5
| 2 | 6 | item5 | <---- j=2 => i=6
| 2 | 7 | item6 | <---- j=2 => i=7
| 3 | 8 | item7 |
+---+---+------+

View Replies !
Getting Rows That Are Related To Other Rows In The Same Table
I use a table to save a map using the following structure:

id, x, y, owner

Every occupied map filed has an owner id != 0. The owner id is = 0 for vacant fields.

now the problem:

New registered users need a vacant field on the map. Moreover the mapfields around this field need to be vacant as well! (sqrt((t1.x-t2.x)*(t1.x-t2.x)+(t1.y-t2.y)*(t1.y-t2.y)) <= 5.25)

What I need is a query that gets those fields that have vacant fields around them.

So far, all my tries to solve this problem with Joins/Suvqueries failed.

View Replies !
Updating A Database Field Based On A String Or Filename
I am using MySQL to store images that I serve up with Coppermine photo gallery. Each image is shown in low resolution format. I also store medium and high resolution versions of these files for download. There is a caption field where I put these links using BBcode. It looks something like this: Code:

View Replies !
Select Based On Two Rows In Mapping Table
I have a many to many relationship between a resource and tag:

resource - 1:M - tagged_resource - M:1 - tag

So a resource can have many tags and a tag can belong to many resources. The data would look like this:

RESOURCE TABLE
id: 1
name: resource1

TAG TABLE
id: 1
tag: new
id: 2
tag: tested

TAGGED_RESOURCE
resourceID: 1
tagID: 1
resourceID: 1
tagID: 2

How can I select the single row from the RESOURCE TABLE which has the tags 'new' and 'tested' in the TAGGED_RESOURCE TABLE?

I have tried using 'IN' but it acts like an OR operator rather than AND.

View Replies !
Detecting Duplicates Based On One Field In A Table?
I can't seem to find an answer anywhere for this as most people want to delete duplicate records.

I have a table, lots of fields, one of which is "title". I want mysql to return all the rows where "title" is the same. For instance if "title" was "Lord of the Rings" on id = 1 and id = 2, then the query would return both of the records, but ignore the others. It doesn't matter what the other field values are.

I have found some
SELECT COUNT( * ) AS num_entries, title
FROM title_table
WHERE title >1
GROUP BY title

But this doesn't seem to work, although looks like it's on the right sort of lines?

I'm not a Mysql expert, so my experience is mostly limited to the usual select, insert, update and delete queries!

View Replies !
Updating Table Field From Another Table Field
I have a field called 'tel1' in table 'live_properties'
and I want to update a 'tel1' field in 'live_properties'

with

'phone_num' field from 'usersTBL'

MYSQL code is here but giving error any suggestions

UPDATE live_properties SET tel1 (SELECT phone_no FROM usersTBL WHERE username = live_properties.username)

View Replies !
Returning Rows In Left Table Based On Mutliple Criteria In Right
This is starting to get to me. I'm sure there's a simple way of handling what i'm trying to do, but someone might be able to help out quicker than spending another hour searching and testing for this. Here's the problem:
Simplified tables:
ARCADES
=======
ID,
name
GAMES
======
ID,
name
ARCADES_GAMES
=============
ID,
arcade_iD
Games_ID
Straightforward enough so far right? I'm trying to get all arcades that have ALL games in a passed in set of game_id's. So for instance I might want all arcades that have the games 11 and 14, but it must have both those.
I can do soemthing like...

SELECT a.name
FROM arcades a
WHERE EXISTS(SELECT 1 FROM arcades_games
WHERE arcade_id=a.id AND game_id IN (11,14))
But that'll return all rows that match ANY of (11,14) rather than ALL of 11,14.

It all comes down to the simple thing of getting rows in a table where all criteria from a list is met, but any advice on how i would do something like this?

View Replies !
Select Rows Where A Field Value Exists In Another Table
I have a table with a column of email addresses I have a second table with a column of email addresses I want to select all the rows in the first table whose email value exists in the second table Can't get a query to do this without an error,

View Replies !
Selecting Data Form One Table That Is Based On An Entry In Another Table
This is the code I am using:

***********
SELECT co_name,city,country,logo_small FROM $info WHERE $info.co_name=$categories.co_name AND WHERE $categories.everyday_wear='y' ORDER BY co_name ASC
***********

I am using a while loop in php to loop through all of the records but no records are being displayed. What am I missing? Do I need to use a JOIN statement?

View Replies !
Select Data From 1 Table Based On Criteria From Another Table
is it possible to select all the data in one table based on a criteria from another table?

for instance i want to select all the therapist from massage_therapist WHERE massage_schedule.finish > 0.
i don't want merged results. i just need to list all therapist based on the where criteria from a different table.

these two tables have the therapist_id in common.

View Replies !
How Do I Generate Results Based On Totals Of Another Table But For 1st Table?
This is what I want to do:

1- I have Two tables: polls_created and votes

2- Table polls_created is like:

poll_id
owner
poll_subject

3- Table votes has the votes issued for a given poll, like this:

vote_id
poll_id
vote
vote_date

So what I need to do is to look at these 2 Tables and generate results based on values of these 2 tables.

How do I then generate this result:

MySQL Code:
SELECT poll_id, owner, poll_subject, COUNT(vote_id) AS number_of_votes FROM polls_created, votes
"sorted by polls that have gotten most number of Votes"

Of course "sorted by polls that have gotten most number of Votes" is not real MySQL

View Replies !
Front End For Updating Several Related Tables
Is there a simple front-end that would let me select records from
multiple related tables and edit their field data?

Right now, I am opening each table individually in mysql control center,
entering the new record, or editing the existing one, then moving on to
the next table.

I know there’s got to be something better, and I am to
busy (spelled overloaded) to create my own from scratch. I use python
now for most of my sql scripts, and PHP on occasion, but could figure
out and modify something simple if necessary.

View Replies !
Consolidating Values In One Table, Updating In Another Table
Table1
==========
Shoes Color
------ -------
Reebok Red
Nike White
Reebok Black
Reebok Blue
Nike Orange

How can I consolidate the values and copy them into a different existing table (Table2) so that Table2 looks like this? :

Table2
==========
Shoes Color
------ -------
Reebok Red, Black, Blue
Nike White, Orange

View Replies !
Update Table Based On Email In Another Table
I'm having trouble updating the entries from a table. The situation is as follows:

Customer table contains:
1) customer_email_address
2) customer_newsletter (value 0 or 1)

Visitor table contains:
1) email

The visitor table contains email addresses from customers that have signed up through another system.

I would like to update the customer table and set customer_newsletter to 1 where customer_email_address matches email from the visitor table.

View Replies !
Selecting From A Table Based On Info In Another Table
Essentially this is what i want to do. I have two Tables,

Table A- has the field "id" which is the primary key
Table B- has the field "id" which is the primary key


Select * from tableA where Table A.id is not in tableB.id


How can i form a statement that will accomplish the above.

View Replies !
DELETE With Related Table
I have a table (tableA), with a data field (saved as a VARCHAR in
YYYY-MM-DD). I have a second table, tableB, which has a field with an int
field which refers to the ID of tableA (or is null). I call this field
tableB.idA

I am trying to delete rows in tableA where the date is less than a specified
value AND there is no reference to said row in tableB.

But how to specify this in SQL. I tried :

DELETE FROM tableA WHERE tableA.date <'2007-01-01' and tableB.idA!=
tableA.id;

only to get the exception Unknown table 'tableB' in where clause.

View Replies !
Counting Records In Related Table
I'm trying to construct a single query that returns all records from one table plus a count of all corresponding records in another table. I have a table of members (members) and a separate table (traffic) that tracks what each member has downloaded from the website I've created. Here is the current SELECT statement I'm using:

SELECT * , COUNT(*) AS traffic_count
FROM `members` , `traffic`
WHERE members.id = traffic.member_id
GROUP BY members.id
ORDER BY traffic_count

This almost works for me. The problem is that it only returns results for the members who have corresponding records in the 'traffic' table. This is a great start but I'm trying to return all records from the 'members' table including a corresponding 'traffic_count' variable for each member. This means that for each member that has no entries in the 'traffic' table I'd like the 'traffic_count' variable to be 0.

View Replies !
Forum Related Table Structure
I didn't know whether to post this in the php forum or mysql--we'll try this one:

Suppose that I have a mysql-php based forum running. Users table (simplified) looks like:

Users
------------
user_id (int, primary_key)
username (varchar(30))
password (varchar(30))
read_post_ids (text)


Currently, 'read_post_ids' is a comma-separated list of all the post ids that a user has clicked on, which are marked as such.
Currently a php script is resposible for reading the list into an array, looping through to find values if needed, and on a write back to the db it takes the array and turns it back into a CSV string.

Problem: The table isn't even in 1NF because of this field, and extra processing is going on. As an alternative, I have considered dropping 'read_post_ids' from this table, and starting a new table:

Read_Post_Ids
-------------
id
read_post_id
user_id

This normals the tables and makes queries easier, but I worry about storage. Let's say I have 10,000 forum users, that on average read 20 posts per day. that is 200,000 table rows per day. In a year, I have 71,000,000 rows. If I index the fields (as I probably should for speed), the rows take up even more room. If I decide to only allow a user a maximum of 300 stored 'read posts' (for example), then I probably have to add a timestamp field so I can delete the older ids, which takes up even more space.

So is there a preferred method here? I would prefer that the tables be normaled, but I worry about the table growing out of hand in terms of size, and at some point becoming slow.

View Replies !
Table Based On Info In Another Table
Essentially this is what i want to do. I have two Tables,

Table A- has the field "id" which is the primary key
Table B- has the field "id" which is the primary key


Select * from tableA where Table A.id is not in tableB.id

How can i form a statement that will accomplish the above.

View Replies !
Creating New Table Based On Old Table
I have a MySQL database with a user table will lots of DUPLICATE email.

I want to delete the rows completely having the duplicate email.

I found a way out is to use some thing like this:

Code:
insert into newtable (email)
select distinct email from oldtable
But this way, only the email column is populated in the new table. I want all the other columns as well.

View Replies !
Query The Article Table And Get A Count Of All Related Comments
Could someone please help me with this query. I have two tables -- one for my articles and another for my comments. Comments are stored in the comments table with a corresponding article id.

I want to query the article table and get a count of all related comments. The following query doesn't seem to work for me. Can you please suggest how I fix it?

SELECT a.id AS id, a.title AS title, a.preview AS preview, a.thumbnail AS thumbnail, a.category AS category, a.timestamp AS timestamp, a.game AS game, count( b.id ) AS commentcount
FROM article_table AS a, comment_table AS b
LEFT JOIN comment_table ON a.id = b.article
WHERE a.news = 'Yes'
AND a.type = &#391;'
AND a.saved != &#391;'
GROUP BY b.article
ORDER BY a.timestamp DESC
LIMIT 5

View Replies !
Updating 2 Fields Based On Search
I'm trying to change 2 database fields based on another.

I want to update te fields levelend and level (expiration date and membership level) based on the field "gender".

So if the gender field reads "K", I want to change levelend to 2556100861 and level to 38

For some reason I just can't get it quite right.

View Replies !
ORDER Based On One Field But LIMIT Based On Another?
Say I have a table with students and their grades, and I want to get the students with the top 10 grades, but the result to be sorted based on their name. How would I do that?

View Replies !
Delete Rows From Table A, Which Dont Exist In Table B (base On Column X)
I have 2 tables identically structured.

A & B

Table A, has column: Product (product code) as primary key

Table B doesn't.

Apart from that they have the exact same fields.

There's also a column: supplier

I want to

Delete * from table A, where does not exist in B (based on column: Product) & where supplier = apples

So to elaborate. Table A is my main table, but it now contains outdated products from supplier apple. Table B has the latest list of products from supplier apple. So I want to remove old products from A that supplier apple no longer makes.

mysql version 4.0.27

View Replies !
Help With Moving Data From One Table Field To Another Table Field
I am a relative newbie at this so would appreciate help - already searched and found and tried several suggestions for similar issues - but nothing quite worked!

I need to move a membership roster to another table in the same db - currently the data is at jos_users1 and it needs to be moved to jos_users. The jos_users1 table has only one field, named email.

The jos_user table has several fields including the email field, and already has data in it - so I don't want to overwrite the table - just upload the additional email addresses into the table.

View Replies !
ALTER TABLE Deleted The Rows - Error: Table Is Full
Today when I tried to insert data in a table i received the error that 'table is full'. On SHOW TABLE STATUS, I noticed the size of table is grown to 4GB (rows 5359211).

mysql> SHOW TABLE STATUS LIKE 'messages' G
*************************** 1. row ***************************
Name: messages
Engine: MyISAM
Version: 9
Row_format: Dynamic
Rows: 5359211
Avg_row_length: 801
Data_length: 4294967288
Max_data_length: 4294967295
Index_length: 45783040
Data_free: 0
Auto_increment: 5406252
Create_time: 2007-04-20 18:26:38
Update_time: 2007-08-22 09:55:22
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
Here is the table structure.


CREATE TABLE `messages` (
`id` int(11) NOT NULL auto_increment,
`subject` varchar(255) NOT NULL default '',
`message` text NOT NULL,
`attachment_path` varchar(255) default NULL,
`new` tinyint(4) NOT NULL default &#390;',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

On searching I found the this link.
http://dev.mysql.com/doc/refman/4.1/en/full-table.html

According to manual i executed the following query

MySQL
ALTER TABLE messages MAX_ROWS=20000000000;
I skipped AVG_ROW_LENGTH from the query, I was confused what should be the value for this.

After executing the query, when i check the table status it displayed totally different picture. Now there were only 170109 rows left.


mysql> SHOW TABLE STATUS LIKE 'messages' G
*************************** 1. row ***************************
Name: messages
Engine: MyISAM
Version: 9
Row_format: Dynamic
Rows: 170109
Avg_row_length: 649
Data_length: 110563036
Max_data_length: 281474976710655
Index_length: 1961984
Data_free: 0
Auto_increment: 5409214
Create_time: 2007-08-23 10:07:08
Update_time: 2007-08-23 13:41:57
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options: max_rows=4294967295
Comment:
1 row in set (0.00 sec)
What could be the reason of this rows deletion?

I am on 32 bit system.
MySQL version: 4.1.18-standard-log
Operating System : CentOS 3.x
Memory: 4 GB DDR

View Replies !
Updating Table
I have two tables:

table1:
id code
1
2
3 aa
4

table2:
id code2
1
2
3 xx
4 zz

I am looking for a way to update table1 with some sort of sql statement. I looked into update and joinn but I couldn't find any relevant information. The reason I don't have any success is prbably because I don't have the correct keyword.

View Replies !
Updating Table Value
update jobs set paid=true where jobid in (SELECT jobid from jobs where CreatedBYusername='roop')

after executing this query i got an ERROR:

You can't specify target table 'jobs' for update in FROM clause.....
same thing i executed in mssql....how can i do this in mysql

View Replies !
Updating One Table With Another
My table contains a product number field 'packCode' but some clients may have their own internal product code. I have created a table ('configurators') which contains our product code along with two columns each for clients: their product code and price, i.e.:

packCode, insight_code, insight_price

The client sends me data containing our pack code matched against their product code and price. I wish to merge their data with our price list in the configurators table. The MySQL I have used is:

update configurators
set insight_code=iCode, insight_price=iPrice
where configurators.packCode=config_insight.iPackCode;

(The columns from the client data are preceded with 'i', i.e. 'iCode', 'iPrice' and 'iPackCode')

However, when I run the query, I get the unusual error

"ERROR 1109 (42S02): Unknown table 'config_insight' in where clause"

suggesting that the table 'config_insight' does not exist, which it clearly does. Is this the correct way to merge data from one table into another? Is my SQL query valid or am I missing something?

View Replies !
Partially Updating Records Based On Pattern Match
I would like to know if it is possible to a (string) replace on
existing records based on a given pattern.

Let's say I have a table containing the following records (strings):
Windows/98
Windows/98/Registry
Windows/2000
Windows/2000/Registry

Is there an SQL method for scanning all records in the
table for the pattern "Windows/98" and then, when a match is made, replace
only the "Windows/98" part of the string with "Windows/2003"?

I am having a hard time figuring this out.

View Replies !
How To Delete Rows In A Table Where Url Shows Only 1 Time In Whole Table
I don't know a whole lot about mysql, i need to fix some things in my db and what i described in the title is the first thing id like to do.

Now, I have a table which lists referring urls, clicks to them and the time. Everytime i get a hit from lets say url1.com it gets a new row with a time id (like 1218613809). I am not resetting this table since it has to track the incoming hits forever since the moment they start sending traffic.
But now the table starts getting the hickups now and then, it has about 850.000 records in it and it cant handle it anymore. I need to do a 'repair table' action and then it's good again, but it happens more and more often lately.

So first i want to delete the rows of the urls who have only sent me 1 click. These urls who sent me 1 click only have one row. When an url sent me 20 clicks, that url is in 20 rows in the table.

So I want to delete the rows of the table with the url's that only show once in the entire table. How do i do this?

View Replies !
Inserting Rows From Backup Table To Current Table
I have two tables, with identical structures. One is a mysqlorary table loaded with the information from the current table a few weeks back - it is essentially a backup table. I now need to insert a selection of data from the backup table into the current table. If an item from the backup table exists in the current table, it is to be overwritten.

I was wondering on the best way of doing this? Would it be better to loop through a php array of table rows, and delete from the current table then re-insert from the backup table? If so, how would i maintain the primary key (it's auto-incrementing)? Or should i write the rows to be transferred from the backup table to the current table to a file, then use load data in file? Are there any other ways of doing this?

View Replies !
Updating Flat Table
I have a database of books that was originally created as a flat file.
Each record has a number of fields, including the authors name. I'm
trying to convert the database to something a little more efficient.
I've created a new table (called Authors) of unique authors names and
assigned each one a unique ID. I've added a new field in the original
table (called Books) for the author's ID. Now, I need to update the
original table with the author ID from the Author's table.

Something like this:

UPDATE Books SET AuthorID = Authors.AuthorID WHERE AuthorName =
Authors.AuthorName .

View Replies !
Updating Table With Datetime
I have a datetime field in a table and when I ran an update like so:

UPDATE myTable SET number=2 WHERE ID=50

I had the old datetime information in the table and that got
overwritten when I did the update. Now I am sure there is no way of
getting that back (yup, believe it or not I didn't do a backup) but
just a general question, should i have done the update like so:

UPDATE myTable SET number=2, mydatetimefield=mydatetimefield WHERE
ID=50

to keep the same information in the datetime field??

View Replies !
Checking Then Updating A Table
I have a form which fills a 'vehicledata' table with a dataitem and datatype

dataitem = saab, datatype = manufacturer
dataitem = petrol, datatype = fueltype
dataitem = automatic, datatype = transmission
etc..

I then I have a form through which a vehicle is added to a 'vehicles' table, with the vehicle data being picked from the vechicledata table.

The 'vechicles' table has a colum for each of the datatypes above.

I'm now working on an edit function, so that the names of the dataitems can be edited (if a spelling mistake was made etc).

I need to check the 'vehicles' table, to warn the user that a dataitem is being used, and the dataitem will be updated. (and then updating any incorrect instances to the new dataitem name).

But I'm stuck with the following:

This means checking the whole ''vehicles' table (looping through each datatype column) for the dataitem, and then updating the whole table. I can't work out how to do this! Does anyone have any suggestions?

View Replies !
Table Data Updating
I've heard that oracle will update data in a table when a specific event occurs and was curious if mySQL will do the same?
For my site I'm designing a comment section that will be attached to my news section. My database organization scheme will consist of two tables. One table that will hold all the news entries and another that holds all the comments. Thus, when browsing the news section visitors initially only access the news table, and once they click on the comments tab then they will access the comments table. Figured this was the best way to organize the data. However, I want the news table to contain the number of comments that exist for that news-section so that the count can be displayed.
My question is how can I make the news table update its data column containing the count for comments when the comments table recieves an update? Is this possible at all in mySQL? If there is a resource someone could point me in let me know, or if anyone has suggestions of a type of hack that would suffice as well

View Replies !
Updating A Table Which Contains Many To Many Relations
1- Delete the existing entries and insert the new entries. 2- Select the existing entries. Compare the existing and newly submitted entries and do a delete or insert or both depending on the options chosen.

1 is easy to do, but i have a faint doubt that recalculating the indexes can be time consuming. Two queries are required for each edit.

2 takes a bit more computing but the number of rows added or deleted is reduced. Two-three queries will be required. One is select, then insert or delete or both depending on the edits made by the user.

View Replies !
Updating A Mapping Table
I have a Publications table and a Themes table. There is also a mapping table for these tables as well.

When I input new records into Publications, my mapping does not get updated. When I delete, then the mapping table will get updated. (This is MySQL 4.x, so no trigger statements.)

My fear is that as I use the mapping table to display some information on a Web page, I will need to update that table "by hand" after I've entered a new record for Publications. Is there some method that I don't know of that will update my mapping table whenever I put in new records into Publications (esp. via a Web form)?

This is the setup for the mapping table: it has foreign keys on the primary key (ID) column of both Publications and Themes. That's it, nothing else in there.

View Replies !
Updating Table Privileges
Running MySQL 4.1.14 through Yahoo. When I access Privileges, I receive the following notice:

""Warning: Your privilege table structure seem to be older than this MySQL version!
Please run the script mysql_fix_privilege_tables that should be included in your MySQL server distribution to solve this problem!""

The Scripts folder does not include this file, and I do not know how to execute a fix for the above issue. Is there a way around this (i.e., uploading the mysql_fix_privilege_tables.sql script to run it, and if so, where can I obtain it?)

View Replies !
Updating Table From File
I have a table and I need to update records in one column. There are 450 records in the table. I know I can insert records to table from file, but is there a way to update records from file?

View Replies !
UPDATE Based On Value In Another Table
How do I update a table to remove orphaned references to a second table? I've deleted rows in the second table, which has a unique auto_increment key. The first table now has references to keys that no longer exist. I need to update the first table, setting the value to NULL where the referenced key no longer exists. Something like:

UPDATE table1 SET table2ID = NULL WHERE table1.table2ID NOT FOUND IN
table2.ID;

The NOT FOUND IN isn't SQL, of course, but I'm not sure what should go there.

View Replies !
Update Based On Another Table
Is it possible to do an update in MYSQL based on another table? I have version 3.23 and when I try to run this statement:


UPDATE ApplicationTbl
INNER JOIN AcademicTbl
ON ApplicationTbl.CampusID = AcademicTbl.CampusID
AND ApplicationTbl.Application_Period = AcademicTbl.Application_Period
SET ApplicationTbl.App_Status = 'Qualified'
WHERE AcademicTbl.Sem_OnCampus >= '1'
AND AcademicTbl.GPA >= '2.4'
AND AcademicTbl.Judicial_Sanction IS NULL

It keeps saying its wrong. Even though I know its not

View Replies !
Selecting From One Table Based On Another?
I have a table for products

and another table for the type of product it is like this:

I need this is be in a seperate table because one product can be several different types like ring,band,wedding,three-stone,etc.

but how can I then select a product based on criteria from the types table

say I wanted to select all products that are type = "Band" and type != "Fancy" ?

View Replies !
Updating A Table To Increment Values
Question, if I want to update all values in a certain column to increment by one, what statement could I use? In quasi-MySQL, this is my pseudocode:

UPDATE table SET fields=[previous_val+1] where [previous_val]>[my_val]

Or do I HAVE to run a SELECT query, increment the value, and THEN Update it?

I was just thinking there'd be an easier way.

View Replies !
Table Locking When Updating From DataSet?
I have a bunch of code that updates tables from a VB.Net DataSets.

The original code updated Access2000 tables, I migrated the MDBs to MySql and have converted the data adaptors and command builders to MySqlClient statements.

Does anyone have any code examples to to the table locking using DataSets???

View Replies !

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