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

Join Of 2 Tables

21
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 1469
ronverdonk
4,258 Expert 4TB
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
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 Expert 4TB
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
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...
0
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...
1
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...
8
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...
4
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...
2
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...
2
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...
7
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; ...
52
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.