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




Compare Data Beetwen 2 Tables


MYSQL problem:

I'm trying to copy all unique data from a heap table
to a myisam table:
CREATE TABLE `heap_in` (
`id` varchar(32) NOT NULL default '',
`domain` varchar(50) NOT NULL default '',
) TYPE=HEAP;

CREATE TABLE `last_visits` (
`id` varchar(32) NOT NULL default '',
`domain` varchar(50) NOT NULL default '',
KEY `id` (`id`,`domain`)
) TYPE=MyISAM;


Heap table just record the data. heap_in.id and heap_in.domain are not unique.
While I'm inserting data to myisam table I want to insert just one time the same domain(if it is duplicated) for the same id. Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Compare Tables
Does anyone know if there is any tool that can compare two databases (and the tables) and allow you to create the SQL necessary to make them identical? I.e. creating new tables, adding columns,

Compare Two Tables
I have two tables.

First table is just list of dealers (table name dealers)

Second table is user input of dealers transactions.(Table name is log) The first field of table two is the dealership name (field name is dealership).

Sometime not all dealers in the first table perform transactions.

How can show the dealers that are listed in the first table that are not listed in the second table.

I tried this, but it did not work

select dealers from dealers, log where dealers != dealership

How To Compare 2 Tables ?
I have two tables containing references and I would like to compute the differences but I have some problems. For example

table 1

+--------+
| ref |
+--------+
| A250 |
| B260 |
| G650 |
| D250 |
+--------+

table 2

+--------+
| ref |
+--------+
| A250 |
| B280 |
| Z650 |
| D250 |
| W650 |
+--------+

SELECT table1.`ref` FROM table1, table2 WHERE table1.`ref` NOT LIKE table2.`ref` group by table1.`ref` ;

does not compute corectly the différences.

On the other end :

SELECT table1.`ref` FROM table1, table2 WHERE table1.`ref` LIKE table2.`ref` group by table1.`ref` ;

computes correctly the comon references.

So what is wrong in the first query ? What can I do to see the differences between my 2 tables ?.

How Do I Compare Two Tables?
I have two tables with the same columns.Table A and Table B. I would like to compare a column in bot tables and determine if there is an entry in A but not in B, also I'd like to determin if there is an entry in B but not in A. How would I do this?

Compare Tables
I am looking to figure out a way to compare two tables and show me what is different.
One table is 'usertable'.This table contains 5 columns reference(key),tag,datatype,scantime,description. When I run my application,it takes a snapshoot of 'usertable' and create a temp table 'temptags'.Every couple of minutes I want to compare the two tables and determine what is different. Fist off,I want to compare the reference column of each table and determine if there is a new reference index or if any have been deleted.Then I want to look at all the other column and determin if any have changed.

These two tables are located in different databases 'usertable' is located in 'user' database and 'temptags' is located in 'tags' database.

Compare Two Tables
there is a way to compare fields and rows in two tables and display the values that differ from each other.

Example: I have a table called "products", and a table called "products_bak", with a few fields: id, name, quantity. "Products_bak" contains yesterdays values, and "products" contains todays updated values.

"Products_bak.quantity" contains yesterday's stock, and "products.quantity" contains current stock. Is there a way to compare the two tables and get the differences. I would like to be notified that the stock has increased from 3 to 5 in the first row, and that the name has changed from "TestOld" to "TestNew".

Compare Two Tables
How can I compare two tables and receive only the entry that are not the same as the first table.

Example:

First Table (fruit); contain apple, orange, lemon and lime. Second table (remove); orange, lime.
I need to have only apple and lemon as the result of my SQL SELECT.

Compare Data
I want to compare data in a single table, and get the index number as well (if these columns have same data/or under the condition i setup).

example:

table:
index ---- col1
1 ---- 260
2 ---- 240
3 ---- 330

I would like to compare these col1 data and return the number(s) which is the largest (the other case is +/- 30 of the smallest). And return the index of the number(s) too.

Compare New Data
I have a bunch of feeds and I was wondering how I would compare the old one with the new one and then report the difference? For example, one item I would like to see is if changes were made to a products price like in the example below

Old Data

1 Blah Blah item image.jpg description $24.99
2 New Example pictur.jpg summary $99.99

New Data

1 Blah Blah item image.jpg description $14.99
2 New Example pictur.jpg summary $99.99

Since #1's price was changed, after I upload the information I would like it to say item one's price was change by $10 and is now $14.99. How would I do this or what technique would I use?

Can't Compare 2 Tables' Columns
For some reason, comparing 2 tables using the operator "<>" is not working but using the opposite operator "=" is returning the correct opposite results.

I have 2 tables:
wp_posts with a column called 'post_title'
sas_products with a column called 'sas_product_id'

Both 'post_title' and 'sas_product_id' contain the same type of data, a product ID.

So if I do the opposite query from what I want, it works:

SELECT ID
FROM wp_posts, sas_products
WHERE post_title = sas_product_id
Results give me the 100 rows where the post_title and sas_product_id are equal.

But, if I do the following query, I get 10,000+ results when I should just get 2.

SELECT ID
FROM wp_posts, sas_products
WHERE post_title <> sas_product_id
Can someone help explain what it is I am missing here?

Compare 2 Tables And Delete
i made a rookie mistake in my delete user code and now i got a problem that i still got challenges by the user in my database with the deleted user_id

i have two tables set like so

Table users contains one cell called user_id
Table challenges contains two cells called challenge_to and challenge from - each contain a user_id

i need to get all the user_id `s from the users table and then delete all challenges that contain a user_id not in the list

Compare Fields Tables
I would like to compare two tables, in both tables there is an user field called "user" (table_1.user, and table_2.user). Thee is however a small problem, in table_1 the users are inserted like this: 235463 and in table_2 the users where inserted like this: p235463!

Would it still be possible to compare this fields in some way (By using only the numbers maybe? But how?)

Compare 2 Tables ( <> Operation )
I have a small problem in comparing two tables, that has to return records that are not in the other table.

Suppose I have the following tables:

T1:               T2:
Field1            Field1
------            -------
1                  b
2                  a
d                  c
a                  1
x
z

And, this is the code:

select T1.Field1 from T1, T2
where T1.Field1 <> T2.Field1
group by T1.Field1

I was expecting the result of 2, d, x, z (which are not in T2). Instead, I got all 6 records from T1. I've tried other operation like !=, NOT IN, but came up the same. The Field1 on T1 is primary key.

Compare And Get Result From Two Tables
I'm trying to compare the id from the users table to the id of the white_player in the games table, and provide me with the users name. I think I am close, but unsure of how to actually get the result. Pretty sure the query is good, but not sure what the second line should look like.


$wplayer = mysql_fetch_object(mysql_query("SELECT ".$this->settings->mysql_prefix."users.nick," .$this->settings->mysql_prefix."users.id," .$this->settings->mysql_prefix."game.white_player from ".$this->settings->mysql_prefix."users ".$this->settings->mysql_prefix."game WHERE " .$this->settings->mysql_prefix."users.id = " .$this->settings->mysql_prefix."game.white_player "));
$wplayer = $wplayer->nick;

Compare Record In Two Tables
if there is an easy way to compare a row from table
a, to a row in table b with the same structure/field names and return
those fields which don't match?I have table_a storing the originally submitted applicant information,and table_b storing a version that can be changed. When a user makes a
change I'd like to compare it to the original table to see what fields
were changed, preferably without opening the row from both tables and
going field by field in code to see if they match...

Compare Data By Similarity
I have datum which contains m values (v1, v2, ..., vm) and I would like get a sorted list of such data so that it is sorted by similarity to some given datum k with values (k1, k2, ..., km). Similarity means in this case how many values are the same. Some datum is more similar to the k than some other one if it has more equal values (v1==k1, v2==k2, ... pairs) that the other one.

I made a table Data with (DataID, ValueID, Value) and try this select query to get a list compared to the first datum:

SELECT Data1.DataID, COUNT(*) AS C FROM Data AS Data1, Data AS Data2 WHERE Data2.DataID=0 AND Data2.ValueID=Data1.ValueID AND Data2.Value=Data1.Value GROUP BY Data1.DataID ORDER BY C DESC;

But it is really slow for large data sets.

Is there some better way to store this data into MySQL database and than retrive sorted list?

How To Write Query To Compare Tables
I give in. I can't figure it out, and I know it's one of those things that once I see it I'll think, "OF COURSE!".

I have 2 tables, same DB.

Table 1 is named Policies
Table 2 is named Assignments

Both contain a PolicyID field.

I want to find out which PolicyID entries are ONLY in Policies, and not in Assignments.

So if "Select PolicyID from Assignments" returned the following:
1, 2, 3, 4, 5, 6

And "Select PolicyID from Policies" returned:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10

What do I use to return this? 7, 8, 9, 10

Any nudge, help, clue, etc. would be appreciated. I've looked thru examples of Outer Joins, Inner Joins, Lefts, Rights, Unions, Intersects, etc. and can't figure out which to use, all for what seems to be a simple operation!

Compare 2 Tables And Update One If A Match.
I have two tables "contact_tbl" and "address_tbl". I have a query that compares the email addresses between the two. If a match is found I need to update a specific field in "contact_tbl" with a value of 'yes'. My query is:

SELECT * FROM contact_tbl
INNER JOIN address_tbl
ON contact_tbl.email = address_tbl.email;

This works and I get a nice result set showing records where the email addresses match. I now need to update a field "status" in contact_tbl when there is a match. Have been tinkering with this for a while but not sure of the syntax and placement for the UPDATE code.

Compare And Delete Or Insert Within Tables
I have a CSV file that contains addresses. I need to compare the csv file to a MySQL table (tbl_bl).

Then if the addresses are not found in tbl_bl, I need to add the addresses to another table (tbl_wl) Only if they do not already exist in the tbl_wl table. I can create simple SQL queries but I'm not so sure about something this complex.

Compare Longblob With Binary Data
checking the data of a longblob for equality. assume =
the `data` field is of type longblob. the following statement returns =
the image records with equal data.

SELECT * FROM `image` WHERE `data`=3D?

how does mysql performe the test. does it check the length of the blob =
before comparing the data, or makes it sense to add the length test as =
follows

SELECT * FROM `image` WHERE LENGTH(`data`) =3D ? AND `data`=3D?

Flat File Load And Compare 2 Tables
I'm trying to complete sounds simple, so I'm not sure why I can't understand it. I created two(2) tables with the same values

+------------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+----------+------+-----+---------+-------+
| PNODE | char(10) | YES | | NULL | |
| Source_Directory | char(80) | YES | | NULL | |
| SNODE | char(10) | YES | | NULL | |
| Dest_Directory | char(80) | YES | | NULL | |
| File_Permission | char(10) | YES | | NULL | |
| Size | int(10) | YES | | NULL | |
| File_Date | datetime | YES | | NULL | |
| File_name | char(30) | | PRI | | |
+------------------+----------+------+-----+---------+-------+

My idea is to have a flat file loaded into table a, then have it compare against table b.
- If files exist in both table a and table b, then just ignore.
- If files exist in Table a but not in table b, then add to table b
- if files exist in Table b but not in table a, then remove from table b

I was thinking it would be easier to have a 3rd table to hold the results of the compare, but not sure. I looked at the documentation for "load data infile", but do not konw if it can run the compare during the load.

Compare 2 Tables And Find Rows Which Don't Match (was "Mysql Noob Question")
I have a products table and a products_description table. They both have products_id as primary key. However, products_description table has more products_id keys then the products table. How do i compare the 2 tables and show just the products_id that dont match from products_descripition table?

SELECT products.products_id, products_description.products_id FROM products, products_description WHERE products.products_id != products_description.products_id;

I tried that query but got some wierd results and also the results gave me 2 columns when I just want one.

Data From 3 Tables?
I'm trying in PHP to call out an SQL statement to enter data from 3 tables, now i've done it with two:

Getting Data From 2 Tables
I have 2 tables

table 1
id
date
other infomation....


table 2
id
date
other infomation....


I want to know how to get ALL records from both tables, sorted by date.

Full joins, two outer left joins, and combine. Can someone please give the statement(s) I need to get the info out.

I was thinking of just creating a new table, and dumping the values from both the other tables, but there must be an easier way.

Getting Data From Two Tables
I have 2 tables that I need to work on. From my Client table, I need to go through and look at the client email address for each client (unique email addresses stored in this table). For each client, I need to pull out their name, company name and phone number.

Next, I have to access the Subscriber table, where for each client email address, I access all the subscribers who they have added to their email list. In this table, I have the subscriber email address, plus their name.

For each subscriber email address, I need to send out an email message that contains their sponsor's info from the client table (client email address, name, company name & phone number). Plus, the email that goes out to the subscriber needs to have their name, which is stored in the Subscriber table.

Basically, it looks like this:

for each Client {
   get Client email
   get Client info
   find all Client's Subscribers from Subscriber table
   for each Subscriber {
      get Subscriber email address
      get Subscriber's name
      do variable substitution in the email message
      send out the personalized email to the Subscriber
   }
}

What is the best way to structure all this?

Data From Various Tables
I want to get a list of all files and folders inside of a certain folder.

One thing is important: can I get rid of all the duplicate data that arises from both the entries in `folder` and in `file` having entries like `name` and `last_modified`? When I just use select * from `folder`, `file`, these show up doubly. This is actually my main problem...

So, how would I do this? So basically, there is a certain `folder_id` which I want to examine. All entries in `folder` that have `parent` = that ID should be returned, and all entries in `file` that have `folder_id` = that ID should be returned as well. It doesn't need to be recursive: just one folder's contents are needed.

Data From 2 Tables
SELECT t1.name, t1.items, t2.name, SUM(t2.total) AS tt FROM `table1` AS t1, `table2` AS t2 WHERE t1.name = t2.name AND tt >= 20 GROUP BY t2.name ORDER BY t1.items

I am trying to order the items from table1 based on the total from table2. The problem comes from the WHERE tt >= 20, I always get an error from this. Any ideas on how fix this?

Data From Two Tables
I want to output data from two different tables in one thing of code
i have one table of songs with artist, name, desc etc....but i have another one with ratings. The rating table has a column of an id number that corrosponds to the auto_increment key column of the songs table
i want to get just the rating column from one table
and all of the columns from the other
i have

$query = "SELECT * FROM songs";

but i want it to be like

$query = "SELECT * FROM songs AND SELECT rating FROM ratings WHERE id={$songid}";

is there any easy way to do this?

Add Data To Tables
Iam using full text searches but need some help with them. I just want to know how to add data to the tables etc. Please help me out as I dont know much about MySQL.

How To Insert Data Into 2 Tables At Once
I am realizing now that I have never done this before. I need to insert information - all at once into two seperate tables joined by a fk.

So essentially I need to insert into one table then get the primary id from it and then insert this value long with the other fields - into the 2nd table.

Can I do this without writing 2 insert statements - perhaps using a join?

If so what is the basic syntax?


Get 4 Tables Data In One Query
I am new to mysql relational programming, and creating a tutorial site like pixel2life. I am trying to get the data from 4 tables 1st table is main tutorials table, 2nd is subcategory (subcat) table, 3rd is categories table and 4th is users table. I don't know how to do it exactly, I googled but not got the proper method. I only got some hints http://www.brainbell.com/tutorials/M...ing_A_Join.htm from this site. I've created the following query which selects the title from tutorials table, subcategory (s_cat) from subcat table which reference is available as s_cat_id in tutorials table, then category (cat) from categories table which reference is available in subcategory (subcat) table and username from users table which reference is availble in tutorials table. Can somebody tell me this query is correct or there is any alternate method

PHP

SELECT d.title, s.s_cat, c.cat, u.username FROM tutorials d
JOIN subcat s ON d.s_cat_id=s.id
JOIN categories c ON s.cat_id=c.id
JOIN users u ON d.author_id=u.id

Another Data In 2 Tables Thread...
I've searched several sites, but joining doesn't make sense to me here. Though the concept is confusing to me anyway, so I could be wrong. I've done a lot of work interacting with single tables, but never more than one.

Using MySQL database with PHP.

Table 1: cat_list
-- Has two columns: "id" and "catName"

Table 2: business
-- Has several columns, most of which are not relevant here, except:
-- "industry" which contains an int that is listed in the "id" column from cat_list.


Now, there could be dozens of records within the business table that use the same id from cat_list. But I need to return the list from business and replace the number in the "industry" column with the text in "catName".

In other words, a simple query of business might return:


Name Industry Street
Marathon 15 111 North Main St

But I really want it to replace the 15 with the text from catName so that it would be:


Name Industry Street
Marathon Gas Station 111 North Main St
So what would the code be to do this? Have tried a few things without success.

How To Fetch Data From Two Tables
I am facing some problem to fetch data from two tables..

I have two tables.one is loguser other is access.

In loguser thier is icnumber and creationdate fields In access their is acccode field now i want to print results from these two tables...

i try the query but gives error...

Pulling Data From Two Tables
I have two tables that I need pull data from and present the results in a particular way. Here is the structure of both tables:

Using Sum And Selecting Data Fom 2 Tables

Here is my prob..


ADMIN TABLE
---------------------------------------
adm_id | adm_login
---------------------------------------

FILE TABLE
----------------------------------------------------
id | file | size | adm_id
----------------------------------------------------

Now the result i want is to list all admins with there sum of total file size everyone have uploaded

eg..

Data From Multiple Tables
I am working on a website about sea shells and basically I have 3 tables:

- shell_tb; (table of shells)
- site_tb; (sites where they can be found)
- instrmt_tb; (instruments used for it)

As you may already have guessed there are two columns in shell_tb (site and inst) which may use more than one item from the site_tb and instrmt_tb.
1st. How do I configure the columns in shell_tb in order to accept more than one value?
(I tried:

CREATE TABLE shell_tb (
shell_id INT(1) NOT NULL AUTO_INCREMENT,
shell_name CHAR(40) NOT NULL,
site INT(20) NOT NULL,
inst INT(20) NOT NULL,
PRIMARY KEY (shell_id)
) TYPE=MyISAM;

but no luck at all when inserting more than on value into inst column.) 2nd. How do I retrieve the info from there?

Data From Linked Tables
I have 2 tables:

names (id, firstname, lastname)
addresses (id, ownerid, ownerlastname, address)

I'd like the owner_lastname field in the addresses table to be
automatically filled in from the lastname field in the names table
based on whatever is manually entered in the ownerid field (obviously
ownerid entries correspond to id entries in the names table).

RETRIEVING DATA FROM FOUR TABLES
I need to retrieve data from four tables into one php "$result" with one MySQL query.  The tables are configured as follows:

Images
   ImageID (primary key & the only unique field)
   Serial
   Photographer (all photographers are listed once in the Posters.Photographer field, ie many to one)
   Operator     (only some operators are listed in the Operators.Operator field, not all, ie many to the occasional one)
   Subject (all subjects are listed once in the Subject.Subject field, ie many to one)

Operators
   Operator (primary key)   
   OpField1
   OpField2
   etc

Photographers
   Photographer  (primary key)
   PhoField1
   PhoField2
   etc

Subjects
   Subjects      (primary key)
   SubField1
   SubField2
   etc

The task:  I need to select ALL images from the Images table meeting criteria set by conditionals on fields in that table, eg 'where Serial = "ABCDE"'.  For each hit I need to fetch all the relevant fields from all four tables, relating to the Image, the Operator (where they exist), Photographer and Subject. Obviously I don't need to retrieve the linking fields twice.

"The answer's going to be a left join" I hear you thinking - well, something like that.  Because a straight join between Images.Operator and Operators.Operator results in the correct image data not being retrieved when the particular operator does not appear in the Operators table (there are good reasons for this, the details for many operators simply don't exist or can't be traced).

So, either I add all the Operators that occur in the Images table to the Operators table, even though there is nothing to put in the detail fields, or I need a query that successfully combines all the correct kinds of joins.  I've found a few likely-looking examples to follow on the internet and in books, but all sorts of unexpected things happened when I tried them.  I've read so much about joins that my head's ing.  And I don't learn so fast these days (no hair left to keep the few remaining brain cells warmed up).  I have a suspicion that it's actually less complicated than the guidance makes it out to be...

Data From Linked Tables
I have 2 tables:

names (id, firstname, lastname)
addresses (id, ownerid, ownerlastname, address)

I'd like the owner_lastname field in the addresses table to be
automatically filled in from the lastname field in the names table
based on whatever is manually entered in the ownerid field (obviously
ownerid entries correspond to id entries in the names table).

Counting Data Using 2 Tables
I have two tables, one has students information in, the key fields for this problem are StudentID which is the Primary Key and Gender. The second table has details of reports the students have done, the key fields required for this problem are ReportID (PK), StudentID, ReportDay, Report Date. As detailed below.

Table 1 called Students

StudentID (PK)
Gender

Table 2 Called Reports

ReportID (PK)
StudentID
ReportDay
ReportDate

What I need to do is count the number of Boys who have been on report on Monday between two set dates, I can query Table 2 to get the total number of students who have been on report on Monday between $StartDate and $EndDate but I don't know how to extract the data from Table 1 so that only Boys are counted.

The common link is the StudentID, unique in Table 1. Code:

How To Enter Same Data All At Once Into The Tables?
I want to upload a certain graphic file to all the tables in my MySQL database. (The file will be uploaded into a certain set of cells in all the tables). What is the easiest way to do this using phpMyAdmin? Is there a specific SQL statement or something?

Insert Data Into 2 Tables Using Php
i was wondering how i would go about insert data collected on a php form into 2 separate tables. i want to collect email and password for an admin table and everything else for a separate table why cant i just do this?

$query = "INSERT INTO user_admin (s_email, s_password, salt) VALUES ('$email', '$encrypted', '$salt')";
mysql_query ($query) or die ('Could not register new account.');

$query = "INSERT INTO student (s_forname, s_surname, s_uni_id, s_email, s_course,) VALUES ('$forename', '$surname', '$uni_id', '$email', '$course')";
mysql_query ($query) or die ('Could not register new account.2');

the email and password get stored into the user_admin table but nothing is collected for teh student table do the values such as $forename need to be declared anywhere else before?

Importing Data Into New Tables
I'm trying to add several of the same work fields into different database tables but I'm not sure what syntax to use or if thats even possible. For example if i export an already fully defined table like this one: Code:

Pulling The Data From Two Tables?
i already experienced this before the problem is i can't recall the right function
to use to pull data from MySQL.

Let say i have two tables
TABLE 1= cclp_players
TABLE 2= cclp_players_stats

Now i'm going to use cclp_players to pull data from cclp_players_stats.

Returing Data From Two Tables
i have set up a db with two tables, users and current_users

in users the fields are:

UsrID
UsrEml
UsrPwd
UsrLvl
UsrBlked

and in current users the fields are:

UsrID
UsrIP
LstAccess

when a user is logged in, a record is created in the current_users table and deleted when they log out, what i would like to do is to write an sql statment that returns the UsrID, UsrEml, UsrLvl, UsrBlked and LstAccess for every user in the users table, if there is not a record in the current users field, i would like LstAccess to be returned blank. How do i acchieve this?

Selecting Data From 2 Tables
I have two tables in a database (MS SQL, but close enough). One table, called Table1 has a field BillingAddress. The other, Table2, has a field ShippingAddress.

Is there any way to search both tables for either a BillingAddress or ShippingAddress which starts with something (say, WHERE field LIKE '1 Street%'), then weed out the duplicates and return them all as one field?

Searching Two Tables For Data
i have created a website where the user logs in with an assigned username and password, on login they are asked to enter their prefared username and password to login with in the future.
I have 2 MySql tables piclogin (original table with preset details)
and newlogin which stores the new prefered username and passwords,
I used the coding below to do the original validation :
if($rec=mysql_fetch_array(mysql_query("SELECT * FROM piclogin WHERE username='$username' AND password = '$password'"))){
if(($rec['username']==$username)&&($rec['password']==$password)){
my question is: can a query be created to search both tables for the username and password entered? and depending on which table the information is found in, redirect the user to different web pages?
Can some form of OR statement be used???

Comparing Data In 2 Tables
I have a table of users which is updated once a week by the client sending me a spreadsheet, and me uploading the CSV to my scripts which then import the data into the user table. This all works fine. However instead of sending me incremental data that can be just imported, the client has now taken to sending me a complete data list. The problem with this is that I cannot just empty the user table and re-populate with the new data as I will lose the primary key values which I use elsewhere.

My solution to this was to create a new table for importing with the same structure as my user table, import the csv to there, then somehow compare the tables and add the rows missing from the import table into the user table.

My question then, is this possible using a SQL query. Can I compare 2 tables, and add missing data from 1 into the other as new records? I could code a software solution, but with around 30k records in the user table I think a SQL query would be the best approach.

Comparing Data From 3 Tables
I am trying to wrap my head around the sql statement needed to get the data I need by comparing three tables.
I have three tables: authors, submissions, and ratings.
I need to see all the submissions that a specific author has not rated.

In other words, I compare the submissions table to the ratings table and find instances where there is a submission but not a rating from a particular author (signified by the row rater_id)

I've tried different combinations of INNER and OUTER joins, unions, subqueries... and nothing is working for me.


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