niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Sybase
An example of using intersection between two tables
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
David Kerber
*nix forums beginner


Joined: 18 May 2005
Posts: 40

PostPosted: Tue Apr 05, 2005 9:35 am    Post subject: Re: An example of using intersection between two tables Reply with quote

In article <1112677195.992132.135910@g14g2000cwa.googlegroups.com>,
zeldorblat@gmail.com says...
Quote:
Intersect simply returns the rows that are the same from two different
queries. For example, consider the following:

Table Store_Information
store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999
Los Angeles $300 Jan-08-1999
Boston $700 Jan-08-1999

Table Internet Sales
Date Sales
Jan-07-1999 $250
Jan-10-1999 $535
Jan-11-1999 $320
Jan-12-1999 $750

and we want to find out all the dates where there are both store sales
and internet sales. To do so, we use the following SQL statement:

SELECT Date FROM Store_Information
INTERSECT
SELECT Date FROM Internet_Sales

Result:

Date
Jan-07-1999

That is essentially an INNER JOIN.


Quote:

Let it be known to all that I ripped this off from:
http://www.1keydata.com/sql/sql-intersect.htm
(the very first result in a Google search for "sql intersect")



--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Back to top
ZeldorBlat
*nix forums Guru Wannabe


Joined: 01 Mar 2005
Posts: 272

PostPosted: Tue Apr 05, 2005 3:01 am    Post subject: Re: An example of using intersection between two tables Reply with quote

Intersect simply returns the rows that are the same from two different
queries. For example, consider the following:

Table Store_Information
store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999
Los Angeles $300 Jan-08-1999
Boston $700 Jan-08-1999

Table Internet Sales
Date Sales
Jan-07-1999 $250
Jan-10-1999 $535
Jan-11-1999 $320
Jan-12-1999 $750

and we want to find out all the dates where there are both store sales
and internet sales. To do so, we use the following SQL statement:

SELECT Date FROM Store_Information
INTERSECT
SELECT Date FROM Internet_Sales

Result:

Date
Jan-07-1999

Let it be known to all that I ripped this off from:
http://www.1keydata.com/sql/sql-intersect.htm
(the very first result in a Google search for "sql intersect")
Back to top
amos_s12@zahav.net.il
*nix forums beginner


Joined: 27 Mar 2005
Posts: 3

PostPosted: Mon Apr 04, 2005 6:13 pm    Post subject: An example of using intersection between two tables Reply with quote

Hello

Can somebody can write an example of using the intersection operation between
two tables.

The example will be very helpful to me in writing some of my store procedures

Thanks ahead
Amos
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 4:26 am | All times are GMT
navigation Forum index » Databases » Sybase
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Creating a relationship between 2 tables Andyza Oracle 2 Thu Jul 20, 2006 1:11 pm
No new posts Linking Tables from 2 databases Pratik Shukla PostgreSQL 2 Wed Jul 19, 2006 5:54 pm
No new posts Basic IP Tables issue spec networking 3 Wed Jul 19, 2006 3:57 pm
No new posts deleting tables using script manish shell 3 Wed Jul 19, 2006 5:47 am
No new posts Procedure Dependencies and Temporary Tables phil@querytool.com IBM DB2 1 Tue Jul 18, 2006 10:53 pm

Wide Shoes for Women & Men | Mortgage Loans | Debt Consolidation | Loans | Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1095s ][ Queries: 20 (0.0375s) ][ GZIP on - Debug on ]