473,782 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,c urrenttable).

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

mysql> select * from archivetable,cu rrenttable;
+------------+------------+---------------------+---------------------+
| 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 1788

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

Similar topics

5
1765
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 invoicearc) one will hold current period data and the other will hod out of period data - previous years stuff, which is only used in queries <5% of the time at most. Now can I join these two tables to make one table when doing queries that span...
0
463
by: Jaime Teng | last post by:
Hi, I have a table: mysql> describe archivetable; +-----------+----------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------------------+-------+ | sessionid | char(10) | | PRI | | | | username | char(25) | | MUL | | |
2
1407
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 creating datasets in the Visual Studio.NET designer, Command objects (Update, Insert, Delete) are automatically generated for you based off your SelectCommand value. You then get the benefits of strong typing, which from what I've seen so far are...
2
8969
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 tables are identical in name and structure.
0
1283
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 tells me I am only allowed access to the web site via Frontpage. Even if I could set up a linked table from my desktop PC I understand that querying access tables over the internet would be inviting data loss and corruption. The only way I can...
0
2625
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 find one, I'm posting the question in hope some one of you guys out there will have the answer for me...! I'll start with what I have, then I'll continue to the problem itself.
2
2721
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, rel_movie_rating.movie_id and rel_movie_rating.person.id. Now what I want to do is to find all the movies a certain person has rated and their corresponding rating values. I've tried for a couple of
5
3688
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 XML file. Once my application starts, I load this XML file into a DataSet object using "ReadXML" function. This creates a dataset in memory with 6 tables.
1
1313
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 pricing for each scenario I need to figure out how to write the form so that instead of putting data into the table, it is in effect querying the existing table and then some help figuring out how to write the if ... then query
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.