473,326 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to retrieve two different data from same database and same table.

Database name : bd1
Table Name : schedule
Fields : associate_name, Category, Aux, Time
Raj ABC Login, 9:00:00
Raj ABC Logout 6:00:00
i want the below output

associate_name, Category, Aux, Login Time, Logout Time
Raj ABC Login 9:00:00 6:00:00

Please help me out.. im new to this.

Raj.
Mar 3 '13 #1

✓ answered by Rabbit

Join the table to itself. You will need a ranking column also so that you can join to the next row.

15 2081
Rabbit
12,516 Expert Mod 8TB
Join the table to itself. You will need a ranking column also so that you can join to the next row.
Mar 3 '13 #2
first in a table make one column as a primary key and den use it in another table as a foreign key then it will b easy to retrieve data
Mar 3 '13 #3
Rabbit
12,516 Expert Mod 8TB
@syed, that won't work. We are only talking about one table here, not two.
Mar 3 '13 #4
HI guys Please help me out. i wanted to implement this ASAP in my company without ur help i won't be able to do this
Mar 4 '13 #5
Hi, can you guys show me the SQl statement to retrieve the data in single table as i have shown above ?
Mar 4 '13 #6
Rabbit
12,516 Expert Mod 8TB
This is not a code writing service but if you make an attempt and post your SQL along with a description of the problem with the code, we can help guide you to a solution.
Mar 4 '13 #7
the problem i have mentioned above is not enough ? is that what you are saying. and i have not asked you guys to write a code for me. im just asking how can i get the two set of data in a single line. please go through the question clearly... its a request
Mar 4 '13 #8
single table ... then might be possible try using procedure ...
with if statement ...
if this
begin
bla bla bla
end
else
begin
bla bla bla
end
--------
hope by this u ill get some gelp
Mar 4 '13 #9
Rabbit
12,516 Expert Mod 8TB
The question you have asked is fine. The problem is that you have asked for code. In post number 6, you said:
can you guys show me the SQl statement to retrieve the data in single table as i have shown above
That is asking for code. We are not here to do your work for you. We will gladly guide you along as you attempt the code, but you have to make an initial attempt at it. I have already supplied the method you can use in post #2.
Mar 4 '13 #10
Okay here is the code i have written :

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim  objRS001, objrs002
  3.  
  4. 'Defining connection string, specify database driver and location of the database
  5. sConnection = "DRIVER={MySQL ODBC 5.1 Driver};Server=localhost;Database=homeshop18;Uid=root;Pwd=cfa;"
  6. Set ObjConn = Server.CreateObject("ADODB.Connection")
  7. ObjConn.Open(sConnection)
  8.  
  9. SQLRAJU001 = "select Associate_name, Category, Date, Aux, Login_time from Schedule where Aux = 'Login' and Date >= '" & from_date & "' and Date <= '" & to_date &"' Group by Associate_name "
  10. SQLRAJU002 = "select Associate_name, Category, Date, Logout_time from Schedule where Aux = 'Logout' and Date >= '" & from_date & "' and Date <= '" & to_date &"' Group by Associate_name "
  11.  
  12. Set objRS001 = ObjConn.Execute(SQLRAJU001)
  13. Set objRS002 = ObjConn.Execute(SQLRAJU002)
  14.  
  15. %>
  16.  
  17. <p class="auto-style1">&nbsp;</p>
  18. <h2 class="auto-style13">Associate Attendence Report</h2>
  19.  
  20. <table cellspacing="1" class="auto-style2" style="width: 580px; float: left">
  21. <tr>
  22. <td class="auto-style15"><strong>Associate Name</strong></td>
  23. <td class="auto-style15"><strong>Category</strong></td>
  24. <td class="auto-style15"><strong>Date</strong></td>
  25. <td class="auto-style15"><strong>Aux</strong></td>
  26. <td class="auto-style15"><strong>Login Time</strong></td>
  27. <td class="auto-style15"><strong>Logout Time</strong></td>
  28. </tr>
  29. <%    
  30. do while not objrs001.eof
  31. %>
  32. <%
  33. do while not objrs002.eof
  34. %>
  35. <tr>
  36. <td class="auto-style14"><%=objrs001("associate_name")%></td>
  37. <td class="auto-style14"><%=objrs001("Category")%></td>
  38. <td class="auto-style14"><%=objrs001("Date")%></td>
  39. <td class="auto-style14"><%=objrs001("Aux")%></td>
  40. <td class="auto-style14"><%=objrs001("Login_Time")%></td>
  41. <td class="auto-style14"><%=objrs002("Logout_Time")%></td>
  42. </tr>
  43. <%
  44. objrs001.movenext
  45. Loop
  46. objrs002.movenext
  47. Loop
  48. %>
  49. <%
  50. objrs001.close
  51. objrs002.close
  52. objconn.close
  53. %>
  54. </table>
this is not working ...
Mar 5 '13 #11
Rabbit
12,516 Expert Mod 8TB
I don't know where this ASP code came out of all of a sudden. But since we're in the MySQL forum, the solution should be in MySQL only. So let's work only on the query. You'll need to create a query using the method in post 2.
Mar 5 '13 #12
easy way make one column as a unique identity with that unique you can retrieve the data what ever you want ..........
Mar 5 '13 #13
Rabbit
12,516 Expert Mod 8TB
@syed, that won't work if there are ever gaps in the sequence. As would happen if they delete records. Having a unique id is a good idea. But they would still need to create a ranking column.
Mar 5 '13 #14
Thanks Everyone for you valuable time.. i could not reach to any conclusion.but im stopping this here. Since this is no code writing service i cannot take anymore help. Please dont spent ur time in replying.
Mar 6 '13 #15
zmbd
5,501 Expert Mod 4TB
I've taken the liberty of setting Rabbit's response as the best answer provided within the thread context based on OP's abandonment of the question and robustness of the solution offered.
Mar 10 '13 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Smith | last post by:
I have a situation where I want to pull strings from one table of a SQL 2000 database and find matches for it in other tables of the same database and have those values returned. i.e. In one...
6
by: Chris Tyson | last post by:
I created an Access 97 database a while ago. It is protected by Workgroup Security, and it is not split. In order to compare different sets of results, a colleague has suggested that it would be...
2
by: Alpha | last post by:
Hi, I need to get the value for the 1st record (there is only one row in this table at all time) for the column name LogFilePath. I got the ado.net and the dataset fill and the table...
0
by: Tommy Christian | last post by:
Hi! Anyone who knows about saving serialized data to database, coz I have a problem with that. If I just serialize my session data and then deserialize it, it works. But when I save it...
2
by: =?Utf-8?B?c2NvdHRybQ==?= | last post by:
Hi I am using a SQL Server 2005 varbinary(max) to store word documents in the database. I can retrive the data out into a MemoryStream object ok but I want to be able to use this to display the...
1
by: rdawadiuk | last post by:
hello professnols, In my table I have, among other, two fileds "Activity" and "Accont ID". I use form to fill the data in the table. If the field "activity " is either "deposit" or withdraw"...
1
by: Amita Singh | last post by:
Hi, How to retrieve data from database in data table?
2
by: robin1983 | last post by:
HI, I have a problem with sql query.. Actually, i have three different table eg. table1, table2, and table3. All the three table have same field name. Actually, my problem is that, whenever I insert...
3
by: Shalini Bhalla | last post by:
can i make use of two different connection using different database in a same php file , if yes , then how
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.