If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > to insert a data into a table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #16 (permalink)  
Old 06-28-08, 23:49
varunkrish varunkrish is offline
Registered User
 
Join Date: Jun 2008
Posts: 15
hi
thnk for ur reply
it represent real time data ,as u say that creating two rows in single table ;it vary if the employee 101 went n times u hav to create n rows,how do we how many employee went outside and come inside
Reply With Quote
  #17 (permalink)  
Old 06-28-08, 23:51
varunkrish varunkrish is offline
Registered User
 
Join Date: Jun 2008
Posts: 15
hi
thnk for ur reply
it represent real time data ,as u say that creating two rows in single table ;it vary if the employee 101 went n times u hav to create n rows,how do we how many employee went outside and come inside

i am sure that entry1<exit 1
Reply With Quote
  #18 (permalink)  
Old 06-28-08, 23:52
varunkrish varunkrish is offline
Registered User
 
Join Date: Jun 2008
Posts: 15
Quote:
Originally Posted by buckeye234
OK, now we may be getting somewhere. Let's assume, for this discussion, that all eid's for the entries being discussed are the same, say 101. Let's also assume that there are two rows in the entry table, referred to as entry1 and entry2, and two rows in the exit table, referred to as exit1 and exit2. Let's also assume that the first row in each table is at a time that is earlier than the second row, for example, entry1 < than entry2.

Given this scenario as a starting point:
1. Does this represent the real world data?
2. Can you gaurantee that entry1 < exit1 and exit1 < entry2 and entry2 < exit2?
3. If that is true, can you say the same is true for any number of rows in the entry table and exit table (Again, assuming the same eid for the rows being considered)?

Asnwer these questions and we'll continue from there.
hi
thnk for ur reply
it represent real time data ,as u say that creating two rows in single table ;it vary if the employee 101 went n times u hav to create n rows,how do we how many employee went outside and come inside
i am sure that entry1<exit1
Reply With Quote
  #19 (permalink)  
Old 06-30-08, 08:34
buckeye234 buckeye234 is offline
Registered User
 
Join Date: Sep 2002
Location: Ohio
Posts: 204
OK, given what I believe to be the way the data exists, here is a select statement that returns the data in the order you want:


Code:
select a.eid, a.entry, b.exit
from t1 as a, t2 as b
where a.eid = b.eid
and b.exit in
( select min(c.exit)
  from t2 as c
  where a.eid = c.eid
  and c.exit > a.entry)
Try this out and see if it works. If it does, you can then turn it into the insert statement that you need. If not, then let me know what is wrong.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On