473,405 Members | 2,373 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,405 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 1761

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.