473,320 Members | 2,052 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,320 software developers and data experts.

Need help in querying two tables

Hi,

I have a table:

mysql> describe archivetable;
+-----------+----------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------------------+-------+
| sessionid | char(10) | | PRI | | |
| username | char(25) | | MUL | | |
| logon | datetime | | MUL | 0000-00-00 00:00:00 | |
| logoff | datetime | | MUL | 0000-00-00 00:00:00 | |
+-----------+----------+------+-----+---------------------+-------+

Whenever I do a query, I get results in this format:

mysql> select * from archivetable;
+------------+------------+---------------------+---------------------+
| sessionid | username | logon | logoff |
+------------+------------+---------------------+---------------------+
| 0000000003 | dangco77 | 1996-09-25 20:51:59 | 1996-09-25 21:07:00 |
| 0000000006 | mccarthy | 1996-09-26 06:15:35 | 1996-09-26 06:20:00 |
| 0000000007 | sigmaph | 1996-09-26 06:25:48 | 1996-09-26 06:28:00 |
| 0000000009 | sigmaph | 1996-09-26 08:31:53 | 1996-09-26 08:51:00 |
+------------+------------+---------------------+---------------------+

Now, I have two of these tables (archivetable,currenttable).

My problem is how do I perform a single query such that I get
results from these two tables:

mysql> select * from archivetable,currenttable;
+------------+------------+---------------------+---------------------+
| sessionid | username | logon | logoff |
+------------+------------+---------------------+---------------------+
| 0000000003 | dangco77 | 1996-09-25 20:51:59 | 1996-09-25 21:07:00 |
| 0000000006 | mccarthy | 1996-09-26 06:15:35 | 1996-09-26 06:20:00 |
| 0000000007 | sigmaph | 1996-09-26 06:25:48 | 1996-09-26 06:28:00 |
| 0000000009 | sigmaph | 1996-09-26 08:31:53 | 1996-09-26 08:51:00 |
| 1000265891 | okame | 2003-08-01 13:38:24 | 2003-08-01 13:43:42 |
| 1000265893 | kbs | 2003-08-01 13:38:30 | 2003-08-01 13:38:48 |
| 1000265897 | bdo-albaro | 2003-08-01 13:38:54 | 2003-08-01 14:07:06 |
+------------+------------+---------------------+---------------------+

of course that last query isnt correct but thats the result I want.

any suggestion? I read about using JOIN but I have no idea how to\
make it work for my need.

hoping for your help.

Jaime
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw

Jul 19 '05 #1
0 1758

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: larry | last post by:
Ok I am working on building my skills to convert my apps to LAMP (read I'm a semi noob), and there was one part I was thinking of. If I create two identical MySQL tables (we'll say, invoice and...
0
by: Jaime Teng | last post by:
Hi, I have a table: mysql> describe archivetable; +-----------+----------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra |...
2
by: Elliot Rodriguez | last post by:
As I continue to read more about the benefits of database querying using ADO.NET, I am having a more difficult time distinguishing what the best approach to data retrieval is anymore. When...
2
by: Steve | last post by:
Hi; I am looking for suggestions about how to solve a problem using tsql. I have been asked to create a report concerning 4 tables. Each of the 4 tables is in its own database. The 4...
0
by: Chris | last post by:
Hi all, I have a web site which allows our customers to write data via forms into an access table stored on our ISP's remote server. My question is how do I efficiently retrieve the data? ISP...
0
by: roiavidan | last post by:
Hi, I'm having a bit of a problem with a small application I wrote in C#, which uses an Access database (mdb file) for storing financial data. After looking for a similiar topic and failing to...
2
by: deepstar | last post by:
Hey all I have four tables - person, movie, rating and rel_movie_rating. The important columns in these tables are person.id, movie.id and movie.title, rating.value and rating.person_id,...
5
by: sql_er | last post by:
Guys, I have an XML file which is 233MB in size. It was created by loading 6 tables from an sql server database into a dataset object and then writing out the contents from this dataset into an...
1
by: jslssuze | last post by:
I have 5 tables in access 1 - depth - normalized 2 - duration - normalized 3 - location - normalized 4 - type - normalized 5 - all data - denormalized with lookups to other tables and full...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: 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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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
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.