473,573 Members | 2,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Of 2 Tables

21 New Member
HI

I have 2 tables.

table1 has all dates from DAY1 - DAY7

COL1
---------
DAY1
DAY2
DAY3
DAY4
DAY5
DAY6
DAY7



Table2 has effort entry and a date entry like this
COL1 COL2
----------------------------
DAY3 4

Now i need a SQL that will JOIN these 2 tables and produce the output as

COL1 COL2
----------------------------
DAY1 0
DAY2 0
DAY3 4
DAY4 0
DAY5 0
DAY6 0
DAY7 0


So if no days exist in table2 the value field should be filled with 0.
Dec 8 '06 #1
3 1476
ronverdonk
4,258 Recognized Expert Specialist
Using a left JOIN will give the result, where the columns of table2 that are not in table1 will be NULL.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM table1 LEFT JOIN table2 USING (col1)
produces result:
Expand|Select|Wrap|Line Numbers
  1. +------+------+
  2. | col1 | col2 |
  3. +------+------+
  4. |    1 | NULL |
  5. |    2 | NULL |
  6. |    3 |    4 |
  7. |    4 | NULL |
  8. |    5 | NULL |
  9. |    6 | NULL |
  10. |    7 | NULL |
  11. +------+------+
Ronald :cool:
Dec 8 '06 #2
sravanpalakala
1 New Member
Hi !

Can you help me out . I have a table with set of columns, one of the column is createdon . Now i need to compare createdon column with sysdate. if it is less than sysdate i need to fetch all columns and display.
my createdon is created in database as datetime in mysql .can u give me a query to compare created on and system date.
Dec 25 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
Hi !

Can you help me out . I have a table with set of columns, one of the column is createdon . Now i need to compare createdon column with sysdate. if it is less than sysdate i need to fetch all columns and display.
my createdon is created in database as datetime in mysql .can u give me a query to compare created on and system date.
This question has nothing to do with the title of this thread. So members who lookup thsi forum, based on the thread title, will not see your post. Please open a new thread if you have a new question that has no relation to the title.

For now the statement is:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM table WHERE createdon < CURRENT_DATE;
Ronald :cool:
Dec 25 '06 #4

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

Similar topics

0
3055
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me solve my problem. I'll turn to MySQL doc after getting through this pressing project. Thanks a lot Roger! Babale -----Urspr=FCngliche...
0
2353
by: Soefara | last post by:
Dear Sirs, I am experiencing strange results when trying to optimize a LEFT JOIN on 3 tables using MySQL. Given 3 tables A, B, C such as the following: create table A ( uniqueId int not null default 0 auto_increment, a1 varchar(64) not null default '',
1
16641
by: TeleTech1212 | last post by:
I am trying to select specific columns from multiple tables based on a common identifier found in each table. For example, the three tables: PUBACC_AC PUBACC_AM PUBACC_AN each have a common column:
8
4964
by: Matt | last post by:
Hello I have to tables ar and arb, ar holds articles and a swedish description, arb holds descriptions in other languages. I want to retreive all articles that match a criteria from ar and also display their corresponding entries in arb, but if there is NO entry in arb I still want it to show up as NULL or something, so that I can get...
4
8848
by: Anthony Robinson | last post by:
I was actually just wondering if someone could possibly take a look and tell me what I may be doing wrong in this query? I keep getting ambiguous column errors and have no idea why...? Thanks in advance!!! SELECT AIM.AIMRETRIEVAL.AIMRETRIEVALID, AIM.AIMRETRIEVAL.DESCRIPTION, AIM.ARCHIVERETRIEVAL.ARCHIVERETRIEVALID,...
2
4665
by: dskillingstad | last post by:
I would really appreciate someone's help on this, or at least point me in the right direction.... I'm working on a permit database that contains 12 tables, and rather than list all of the tables, I'll just list a few, as the links are the same for all tables. These tables are: tblPermitMain tblApplicant tblContractor tblEngineer
2
8873
by: Bennett Haselton | last post by:
I know how to create a DataAdapter that loads data from a data source into a table in a typed DataSet, and how to set the DataSource and DataMember properties of a DataGrid so that at run time it will load the data from that table in the DataSet. Assuming I've got two tables in the DataSet, how can I set the DataSource property of the...
7
4155
by: Shanimal | last post by:
I would like to know how to join 2 queries so that the results of these 2 queries show up in the same query: SELECT b.bios_serial_number FROM bios b: SELECT s.system_name FROM system s; Basically I want to create a report that includes both system name and serial number. I'm new to this and none of the JOIn documentation was clear to me.
52
6289
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the...
3
16498
by: Zeff | last post by:
Hi all, I have a relational database, where all info is kept in separate tables and just the id's from those tables are stored in one central table (tblMaster)... I want to perform a query, so all data from the separate tables is shown in a view (instead of the reference id's pointing to the separate tables...) I have some troubles...
0
8000
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. ...
0
8194
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...
1
7767
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8054
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...
0
6398
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5288
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...
0
3729
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2190
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1294
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.