Compare two tables

hi,

Sorry, I'm stuck on this...

I need to know which rows are in A table and not in B table(assuming A 
and B are identical)

I know the ideal query would be

Select *
from A
Where A.id not in(Select B.id from B )


But, this tables have 3 columns as PK( lets say A.country, A.state, A.city)

How could I accomplish this with a query?

BTW, I'm on ASE 15.0.3


Thanks in advance!
0
Manuel
12/1/2010 3:58:25 PM
sybase.ase.general 8655 articles. 0 followers. Follow

2 Replies
1624 Views

Similar Articles

[PageSpeed] 49
Get it on Google Play
Get it on Apple App Store

select *
from A
where not exists (select * from B
                           where A.country = B.country and A.state = B.state 
and A.city = B.city)


"Manuel Espinoza" <jmespinoza_no_spam@seicom_dot_com_dot_mx> wrote in 
message news:4cf670a1$1@forums-1-dub...
> hi,
>
> Sorry, I'm stuck on this...
>
> I need to know which rows are in A table and not in B table(assuming A and 
> B are identical)
>
> I know the ideal query would be
>
> Select *
> from A
> Where A.id not in(Select B.id from B )
>
>
> But, this tables have 3 columns as PK( lets say A.country, A.state, 
> A.city)
>
> How could I accomplish this with a query?
>
> BTW, I'm on ASE 15.0.3
>
>
> Thanks in advance! 


0
Luc
12/1/2010 4:03:49 PM
ASE 15.0 doesn't implement the MINUS operator...  With that, it's as simple 
as:
Select country, state, city from A
MINUS
Select country, state, city from B ;

Paul Horan[Sybase]
http://paulhoran.ulitzer.com

"Luc Van der Veurst" <dba_azvub@hotmail.com> wrote in message 
news:4cf671e5$1@forums-1-dub...
> select *
> from A
> where not exists (select * from B
>                           where A.country = B.country and A.state = 
> B.state and A.city = B.city)
>
>
> "Manuel Espinoza" <jmespinoza_no_spam@seicom_dot_com_dot_mx> wrote in 
> message news:4cf670a1$1@forums-1-dub...
>> hi,
>>
>> Sorry, I'm stuck on this...
>>
>> I need to know which rows are in A table and not in B table(assuming A 
>> and B are identical)
>>
>> I know the ideal query would be
>>
>> Select *
>> from A
>> Where A.id not in(Select B.id from B )
>>
>>
>> But, this tables have 3 columns as PK( lets say A.country, A.state, 
>> A.city)
>>
>> How could I accomplish this with a query?
>>
>> BTW, I'm on ASE 15.0.3
>>
>>
>> Thanks in advance!
>
> 


0
Paul
12/7/2010 9:04:38 PM
Reply:

Similar Artilces:

Comparing two columns in two tables
How do I compare, via SQL, the contents of two, or more, columns in two different tables? The table structures are the same (one is a baseline delivery, the other the current table), but the current table will have more records. I would like to periodically monitor the activity in the table, but don't have auditing and can't modify triggers... ASE 12.0 and Unix Thanks What types of comparision do you want to do? difference in number of rows? values that appear in one but not the other? average value? standard deviation? -bret Jim wrote: > How do I com...

when have 4 Tables how to compare table with 4nd table? ( need to join and compare with datatime)
Table MediaImportLog column ↘ImportIndex     ImportFileTime            ImportSource value    ↘80507             20060506001100          815               80511             20061109120011           CRD &nb...

Comparing two tables
Hi I wish to compare two tables. I wish to find out if entries in one table are similar to the ones in the other tabl. Can someone please provide me with a code fragment to make this comparison. Any help would be appreciated thank you aymbpc I think you need to explain your question a bit more. By tables you mean database tables? What do you mean you want to see if they are "similar?" Do you mean if they match exactly? Have certain columns exactly matching? Have similar substrings? That one is a substring of another?Happy Programming!-- Scott Mitchell-- mitch...

how to insert data into two table when two tables depend on each other?
suppose there are two table called tableA and tableB and the situation is the primary key of tableA is a foreignkey of tableB and the primary key of tableB is a foreignkey of tableA.in this type of situation how we can insert data into 2 tables called tableA,tableB.pls tell me how can i handle this situation very efficiently.explain in detail........plzzzzz. Hello my friend, What you are suggesting is a many-to-may relationship, which is bad.  If you really need to do it this way, you need to remove the constraint so that the fields are there to query but the relationships are n...

Comparing Tables between ASA and ASE
I have just under 100 ASA employee master tables that I have to compare against a master master table on ASE. Is there no simple way to search for incongruous data in either DBMS? or some macro in Excel that will compare worksheets bit for bit?? Worse yet how do I get ASE to export descent excel files? -- Posted via http://dbforums.com Hi, maybe you can use the ASE master master table as a proxy table in ASA and use a simple join ... HTH, Karsten Hoeppner [Hermann O. Eckert GmbH] On 1 Aug 2003 03:34:42 -0700, westsan <member23767@dbforums.com> wrote: &g...

Comparing contents of two tables
Hi All,I am developing one tool using VB.Net which will compare data and schema of two identical databases. I am trying to compare the data of the two databases  by comparing individual tables. The tables in turn will be compared on a row by row basis I am trying to do somethis like this I have mentioned my question in pink color below. Can anyone help me on thisThanks in Advance!! Private Sub CompareData() 'Database 1 Dim conn1 As SqlConnection = New SqlConnection("workstation id=IE10DT2KC03212;packet size=4096;integrated security=SSPI;data source=IE10DT2KC03212;persist security inf...

compare two tables and update
hi friends i have 2 tables  AA and BB AA TABLE HAS LOCCODE AND PERCENTAGE LOCCODE  PERCENTAGE L0001           12 L0002           13 IN BB TABLE HAS LOCCODE  PERCENTAGE L0001 L0002 I WANT TO COMPARE TWO TABLES BY LOCCODE IF MATCH THE UPDATE PERCENTAGE IN BB TABLE   THANKS  GK       UPDATE SET b.PERCENTAGE = a.PERCENTAGE FROM AA aINNER JOIN BB b ON a.LOCCODE  = b.LOCCODE CSR~ Please Mark as Answer if it solves you...

Comparing dates in two tables
 Having some trouble figuring out how to put this together.I have table1(thread) has thread_id and table2(post) has thread_id that are related. table1(thread) has 1 record to many records in table2(post).  Both tables have a datetime field and what i want to do is compare the datetime field in table1 to the records in table2 and get the most recent date along with all its related columns(title, subject, etc).  this can either return the most recent date for table1 record or one of the related records date. So, (if anybody can figure this out) how would i put together a se...

Compare two tables...URGENT!
 Can anyone give me the query,cursor that I can use to to compare the data between two similar tables.Data from col1,col2,col3,col4 needs to be compared. Col1 is primary key in both the tables.It should return with zero rows if they are same.But table1 is in diffrent databse and table2 is in diffrent database"Mark As Answer" If my reply helped you -- Hope the following code can helps out..  SELECT CASE WHEN COUNT(*) = 0 THEN 'Same' ELSE 'Different' ENDFROM (        (        SELECT *...

How to insert into two tables at (Master table and Detail table)
I was hoping that the asp.net/learn/dataaccess would have had a tutorial for inserting into a MasterRecord and DetailRecord.  I have a page that I am working on that is a Reciepe. The Master Record has details such as customer, mix name, create date. The Detail Records has Ingredient Name, Ingredient Amount, etc. I have been following the DAL and BLL concept of the asp.net/learn/dataccess tutorials. Does anyone know of an example that I can follow of setting up two tables and inserting into two tables from the same Button_click event. Thanks, John Hi jfeeney, You just need to reme...

The same table (Table) cannot be the child table in two nested relations.
Hi, I"m getting this error when trying to load an XML document from a third party. I don't have the option of asking them to rename anything. Here's what i'm trying to accomplish. DataSet _ds = new DataSet(); _ds.ReadXml(URL, XmlReadMode.InferSchema); I tried InferSchema, IgnoreSchema and, of course, Auto. I got the same error w/ Infer as Auto (above). With Ignore, I got an empty DataSet. Please help!!! Thanks, kyle.kyleRochehttp://www.kyleroche.com Get that url, and dump it to the browser. It seems like it's not meant to be loaded into a dataset. Or it's...

SQL Quiz: How to compare two tables?
Hello, I need ideas. How do I compare the data in two different tables using a T-SQL select ? I need to know if both tables are *exaclty* equal (same data and # of rows). Any ideas ? Thanks, JC Hello: Supposing the two tables (tabA, tabB) have the same structure, the same number of rows (this is easy to check) and no duplicate rows, my idea is as follows: (a) create a temp table (tabT) with the same structure (b) insert into tabT the rows in tabA (c) insert into tabT th erows in tabB (d) create a clustered index on tabT with ignore_dup_row (e) if the numbe...

stored procedure not inserting into linking table properly - two tables
Hi can anyone help me with the format of my stored procedure below. I have two tables (Publication and PublicationAuthors). PublicaitonAuthors is the linking table containing foreign keys PublicaitonID and AuthorID. Seeming as one Publication can have many authors associated with it, i need the stored procedure to create the a single row in the publication table and then recognise that multiple authors need to be inserted into the linking table for that single PublicationID. For this i have a listbox with multiple selection =true. At the moment with the storedprocedure below it is creati...

Web resources about - Compare two tables - sybase.ase.general

Compare the Meerkat - Wikipedia, the free encyclopedia
Compare the Meerkat is an advertising campaign on British commercial television for comparethemarket.com , a price comparison website, part of ...

How Do Fans Of The New York Giants, Jets Compare On Facebook?
The National Football League ’s New York Giants and New York Jets may share MetLife Stadium in East Rutherford, N.J., but there is no love lost ...

Skyscanner - Compare Cheap Flights (no ads) on the App Store on iTunes
Get Skyscanner - Compare Cheap Flights (no ads) on the App Store. See screenshots and ratings, and read customer reviews.

Apples & Oranges - They Don't Compare - Flickr - Photo Sharing!
I tried comparing apples to oranges... I don't see much resemblance at all! Image Notes: No post production done except Crop &amp; Resize The ...

Bryan Fischer Compares Gay Marriage Ruling To 9/11, Slavery, Pearl Harbor, & Sodom And Gomorrah - YouTube ...
http://www.rightwingwatch.org/content/bryan-fischer-compares-gay-marriage-ruling-911-slavery-pearl-harbor-and-sodom-and-gomorrah Right Wing Watch ...

Bieber compares minor Ferrari crash to Princess Diana's death
New York Daily News Bieber compares minor Ferrari crash to Princess Diana's death 9news.com.au The aftermath of a crash involving Justin Bieber's ...

How Microsoft Surface tablets compare in a crowded market
... Monday, Steve Ballmer and the other Microsoft execs referred to the company's upcoming Surface devices as tablets. So it makes sense to compare ...

Judge compares incest and paedophilia to past attitudes towards homosexuality, claiming they might not ...
A Sydney judge has compared incest and paedophilia to homosexuality, saying the community may no longer see sexual contact between siblings and ...

How American Sniper compares to the biggest war movies of all time
It's hard not to make tacky battle/war/victory analogies when talking about the success of Clint Eastwood-directed American Sniper over the weekend. ...

Broadcaster Alan Jones compares A-League arrests to 'terrorism in Paris'
Controversial broadcaster Alan Jones might have some explaining to do to his listeners this week after comparing arrests at A-League games to ...

Resources last updated: 12/1/2015 11:13:07 AM