Results 1 to 3 of 3

Thread: Query Problem with mysql

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Query Problem with mysql

    Hi,

    I'm using mysql as database and VB as programming language. I have four table which is buyer2005, buyer2006, good2005 and good2006, the last four digit represent year.

    My question is how to make SELECT subquery or join in MySql which second table name come from one field on first Table?
    Example:
    SELECT T1.GoodCode, T1.GoodName, T1.BuyerCode, T1.DatePurcashed, T2.BuyerName FROM good2005 AS T1 LEFT JOIN buyer--MID(T1.DatePurcashed,1,4)--

    How to do that?
    I just migrate from Foxpro whom is give me possibility to do such thing. If there is no other i will redesign my database.

    Thank you

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Query Problem with mysql

    I don't quite understand what you are looking to do. Could you post some sample data for each of the tables and how you want the data returned from the query. Secondly, if I were you I would normalize that database and do away with year specific tables (buyer2005, buyer2006, good2005 etc.) I would create a new table based upon the schema of your tables and I would add a new field that will be used to hold Year value. THis seems to me to be a better approach to your problem.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Query Problem with mysql

    Sorry, right now i can't give you sample data. And after "deep" thinking, yes i will normalize the database.

    Thanks Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width