Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 19th, 2003, 04:07 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Table joins

hey,

I have seven different tables that i need to join together and order in ascending order by a colum named 'real_date'. Each table is set up in the same format, but holds different data. The first table is named '1_dates' and the second '2_dates'. The other five follow the same pattern. This is the SQL statement:

select * from 1_dates, 2_dates, 3_dates, 4_dates, 5_dates, 6_dates, 7_dates ORDER BY `real_date` ASC

When I try this query I recieve this error:

MySQL said:
Column: 'real_date' in order clause is ambiguous

Does anyone know what the problem is, and how i can fix it?

Thanks

Reply With Quote
  #2  
Old July 19th, 2003, 08:15 AM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Table joins

If these errors appear, there is something seriously wrong with the normalisation...

Reply With Quote
  #3  
Old July 19th, 2003, 08:30 AM
Ashkhan Ashkhan is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 372 Ashkhan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 57 sec
Reputation Power: 2
RE: Table joins

I would say that in your query you have to identify the real_date. If your tables have identical structure and each have the real_date column, MySQL simple don't know which one to use.

select * from 1_dates, 2_dates, 3_dates, 4_dates, 5_dates, 6_dates, 7_dates ORDER BY 1_dates.real_date ASC;

If it is in first 1_dates table.


Reply With Quote
  #4  
Old July 19th, 2003, 01:59 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Table joins

When I try the above mySQL generates a huge table. I think I might be going about this the wrong way. What I need is all the dates from each table listed together in ascending order. Each table has a colum named 'real_date' that holds a date vaule in yyyy-mm-dd form. Im wanting mySQL to be able to create a single table that has only one colum which will show all the dates from all the tables in ascending order.

Does anyone know if this is possible, or how to do it?

Thanks

Reply With Quote
  #5  
Old July 19th, 2003, 02:05 PM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Table joins

Why do you have 7 different tables, with the same structure? :s

Reply With Quote
  #6  
Old July 19th, 2003, 02:41 PM
sliver's Avatar
sliver sliver is offline
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 897 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 44 m 13 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Table joins

Yeah that's a major problem.

Reply With Quote
  #7  
Old July 19th, 2003, 02:44 PM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Table joins

And seems stupid to me...

Can't you normalize the database structure? Is a lot more effective

Reply With Quote
  #8  
Old July 19th, 2003, 07:36 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Table joins

What you're looking for is more along the lines of a union, not a join. UNION is only available in MySQL 4.0.0 and up.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Table joins


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway